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)オブジェクトがハッシュ可能であることが保証されていない場合にのみ適切である。 そうでなければ、 dictset が良い選択だ。

O(n2)O(n^2) この関数は、すべての要素のペアの間で比較を行う可能性があるため、 dictset とは対照的に、最悪の場合、 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で行ってください。