DQCsim
|
Represents an ordered set of qubit references. More...
Public Member Functions | |
QubitSet (HandleIndex handle) noexcept | |
Wraps the given qubit set handle. More... | |
QubitSet () | |
Constructs an empty qubit set. More... | |
QubitSet (const QubitSet &src) | |
Copy-constructs a qubit set. More... | |
void | operator= (const QubitSet &src) |
Copy assignment operator for qubit sets. More... | |
QubitSet (QubitSet &&)=default | |
Default move constructor. | |
QubitSet & | operator= (QubitSet &&)=default |
Default move assignment. | |
void | push (const QubitRef &qubit) |
Pushes a qubit into the set. More... | |
QubitSet && | with (const QubitRef &qubit) |
Pushes a qubit into the set (builder pattern). More... | |
QubitRef | pop () |
Pops a qubit from the set. More... | |
size_t | size () const |
Returns the number of qubits in the set. More... | |
bool | contains (const QubitRef &qubit) const |
Returns whether the given qubit is contained in the set. More... | |
std::vector< QubitRef > | drain_into_vector () |
Drains the qubit set into a vector. More... | |
std::vector< QubitRef > | copy_into_vector () const |
Copies the qubit set into a vector. More... | |
Public Member Functions inherited from dqcsim::wrap::Handle | |
Handle () noexcept | |
Constructs an empty wrapper. More... | |
Handle (HandleIndex handle) noexcept | |
Wraps the given raw handle. More... | |
virtual | ~Handle () noexcept |
Delete the handle and its wrapper. | |
void | free () |
Explicitly delete the handle, allowing errors to be caught. More... | |
bool | is_valid () const noexcept |
Returns whether this wrapper (still) contains a valid handle. More... | |
HandleIndex | get_handle () const noexcept |
Returns the raw handle without relinquishing ownership. More... | |
HandleIndex | take_handle () noexcept |
Returns the raw handle and relinquishes ownership. More... | |
Handle (const Handle &)=delete | |
void | operator= (const Handle &)=delete |
Handle (Handle &&src) | |
Move constructor; simply moves ownership of the handle from the source object to the constructed object. More... | |
Handle & | operator= (Handle &&src) |
Move constructor; simply moves ownership of the handle from the source object to the assignment target. More... | |
std::string | dump () const |
Returns a string containing a debug dump of the handle. More... | |
HandleType | type () const |
Returns the type of this handle. More... | |
Static Public Member Functions | |
template<class T > | |
static QubitSet | from_iter (const T &qubits) |
Constructs a qubit set object from an iterable of qubit references. More... | |
Additional Inherited Members | |
Protected Attributes inherited from dqcsim::wrap::Handle | |
HandleIndex | handle |
The wrapped handle. | |
Represents an ordered set of qubit references.
DQCsim's API primarily uses these objects to represent the gate operand lists for multi-qubit gates. They can also be used to represent multi-qubit registers, but typically a std::vector<QubitRef>
will be more suitable for that, as it supports fast and convenient indexation. You can convert between a QubitSet
and a vector easily using from_iter
, drain_into_vector
, and copy_into_vector
.
You can use the builder pattern to construct qubit sets in a single line:
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
Copy assignment operator for qubit sets.
src | The object to copy from. |
std::runtime_error | When the source handle is invalid, any previously wrapped handle in the destination object could not be freed, or construction of the new handle failed for some reason. |
|
inline |
Pushes a qubit into the set (builder pattern).
Note that qubit sets are ordered. An exception is thrown if the qubit is already in the set.
qubit | The qubit reference to push. |
&self
, to continue building. std::runtime_error | When the handle is invalid. |
|
inline |
|
inline |
|
inline |
|
inline |
Drains the qubit set into a vector.
std::vector<QubitRef>
containing the qubits that were in the set, in insertion order. std::runtime_error | When the handle is invalid. |
|
inline |
Copies the qubit set into a vector.
std::vector<QubitRef>
containing the qubits that are in the set, in insertion order. std::runtime_error | When the handle is invalid. |