Skip to main content
IBM Quantum Platform

반복 유틸리티

qiskit_addon_cutting.utils.iteration

반복 유틸리티.

unique_by_id

unique_by_id(iterable, /)

GitHub

iterable 에서 ID별로 고유한 객체를 반환합니다.

>>> a = {0}
>>> list(unique_by_id([a, a]))
[{0}]
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~collections.abc.ValuesView\``
>>> list(unique_by_id([a, a.copy()]))
[{0}, {0}]

매개변수

iterable (Iterable)

리턴 유형

ValuesView

unique_by_eq

unique_by_eq(iterable, /)

GitHub

iterable 에서 고유한 객체를 반환합니다.

이 함수는 (i) 객체 수가 적고 (ii) 객체가 해시 가능하지 않은 경우에만 적절합니다. 그렇지 않은 경우 dict 또는 set 을 사용하는 것이 좋습니다.

이 함수는 잠재적으로 모든 요소 쌍을 비교할 수 있으므로 최악의 경우 O(n2)O(n^2) 시간에 실행되며, dict 또는 set, 둘 다 O(n)O(n) 시간으로 구성할 수 있는 것과는 대조적입니다.

>>> a = {0}
>>> list(unique_by_eq([a, a]))
[{0}]
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`list\``
>>> list(unique_by_eq([a, a.copy()]))
[{0}]

매개변수

iterable (Iterable)

리턴 유형

목록

이 페이지가 도움이 되었습니까?
GitHub에서 버그, 오타를 보고하거나 컨텐츠를 요청하십시오.