Unordered unique-element container wrapping std::unordered_set. More...
#include <hashset.h>
Public Types | |
| using | Ptr = SharedPtr< HashSet > |
| Shared pointer type for HashSet. | |
| using | Data = std::unordered_set< T > |
| Underlying std::unordered_set storage type. | |
| using | Value = T |
| Value type. | |
| using | Iterator = typename Data::iterator |
| Mutable forward iterator. | |
| using | ConstIterator = typename Data::const_iterator |
| Const forward iterator. | |
Public Member Functions | |
| HashSet ()=default | |
| Default constructor. Creates an empty hash set. | |
| HashSet (const HashSet &other) | |
| Copy constructor. | |
| HashSet (HashSet &&other) noexcept | |
| Move constructor. | |
| HashSet (std::initializer_list< T > initList) | |
| Constructs a hash set from an initializer list. | |
| ~HashSet ()=default | |
| Destructor. | |
| HashSet & | operator= (const HashSet &other) |
| Copy assignment operator. | |
| HashSet & | operator= (HashSet &&other) noexcept |
| Move assignment operator. | |
| Iterator | begin () noexcept |
| Returns a mutable iterator to the first element. | |
| ConstIterator | begin () const noexcept |
| Returns a const iterator to the first element. | |
| ConstIterator | cbegin () const noexcept |
| Returns a const iterator to the first element. | |
| ConstIterator | constBegin () const noexcept |
| Returns a const iterator to the first element. | |
| Iterator | end () noexcept |
| Returns a mutable iterator to one past the last element. | |
| ConstIterator | end () const noexcept |
| Returns a const iterator to one past the last element. | |
| ConstIterator | cend () const noexcept |
| Returns a const iterator to one past the last element. | |
| ConstIterator | constEnd () const noexcept |
| Returns a const iterator to one past the last element. | |
| bool | isEmpty () const noexcept |
| Returns true if the hash set has no elements. | |
| size_t | size () const noexcept |
| Returns the number of elements. | |
| bool | contains (const T &value) const |
Returns true if value exists in the hash set. | |
| bool | insert (const T &value) |
| Inserts a value into the hash set. | |
| bool | insert (T &&value) |
| Inserts a value into the hash set (move overload). | |
| bool | remove (const T &value) |
Removes value from the hash set. | |
| Iterator | remove (Iterator pos) |
Removes the element at pos. | |
| void | clear () noexcept |
| Removes all elements. | |
| void | swap (HashSet &other) noexcept |
| Swaps contents with another hash set. | |
| HashSet | unite (const HashSet &other) const |
Returns the union of this set and other. | |
| HashSet | intersect (const HashSet &other) const |
Returns the intersection of this set and other. | |
| HashSet | subtract (const HashSet &other) const |
Returns this set minus other. | |
| List< T > | toList () const |
| Converts the hash set to a List. | |
| template<typename Func > | |
| void | forEach (Func &&func) const |
Calls func for every element. | |
Friends | |
| bool | operator== (const HashSet &lhs, const HashSet &rhs) |
| Returns true if both hash sets have identical contents. | |
| bool | operator!= (const HashSet &lhs, const HashSet &rhs) |
| Returns true if the hash sets differ. | |
Unordered unique-element container wrapping std::unordered_set.
Provides a Qt-inspired API over std::unordered_set with consistent naming conventions matching the rest of libpromeki.
| T | Element type (must be hashable). |
Constructs a hash set from an initializer list.
| initList | Brace-enclosed list of values. |
|
inlinenoexcept |
Returns a const iterator to the first element.
|
inlinenoexcept |
Returns a const iterator to one past the last element.
Calls func for every element.
| Func | Callable with signature void(const T &). |
| func | The function to invoke. |
Inserts a value into the hash set.
| value | The value to insert. |
Inserts a value into the hash set (move overload).
| value | The value to insert (moved). |
Returns the intersection of this set and other.
| other | The set to intersect with. |
Removes value from the hash set.
| value | The value to remove. |
Removes the element at pos.
| pos | Iterator to the element to remove. |
Returns this set minus other.
| other | The set to subtract. |
other. Swaps contents with another hash set.
| other | The hash set to swap with. |
Returns the union of this set and other.
| other | The set to unite with. |