Ordered unique-element container wrapping std::set. More...
#include <set.h>
Public Types | |
| using | Ptr = SharedPtr< Set > |
| Shared pointer type for Set. | |
| using | Data = std::set< T > |
| Underlying std::set storage type. | |
| using | Iterator = typename Data::iterator |
| Mutable forward iterator. | |
| using | ConstIterator = typename Data::const_iterator |
| Const forward iterator. | |
| using | RevIterator = typename Data::reverse_iterator |
| Mutable reverse iterator. | |
| using | ConstRevIterator = typename Data::const_reverse_iterator |
| Const reverse iterator. | |
Public Member Functions | |
| Set ()=default | |
| Default constructor. Creates an empty set. | |
| Set (const Set &other) | |
| Copy constructor. | |
| Set (Set &&other) noexcept | |
| Move constructor. | |
| Set (std::initializer_list< T > initList) | |
| Constructs a set from an initializer list. | |
| ~Set ()=default | |
| Destructor. | |
| Set & | operator= (const Set &other) |
| Copy assignment operator. | |
| Set & | operator= (Set &&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. | |
| RevIterator | rbegin () noexcept |
| Returns a mutable reverse iterator to the last element. | |
| RevIterator | revBegin () noexcept |
| Returns a mutable reverse iterator to the last element. | |
| ConstRevIterator | crbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| ConstRevIterator | constRevBegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| RevIterator | rend () noexcept |
| Returns a mutable reverse iterator to one before the first element. | |
| RevIterator | revEnd () noexcept |
| Returns a mutable reverse iterator to one before the first element. | |
| ConstRevIterator | crend () const noexcept |
| Returns a const reverse iterator to one before the first element. | |
| ConstRevIterator | constRevEnd () const noexcept |
| Returns a const reverse iterator to one before the first element. | |
| bool | isEmpty () const noexcept |
| Returns true if the 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 set. | |
| Iterator | find (const T &value) |
Finds value in the set. | |
| ConstIterator | find (const T &value) const |
| Const overload of find(). | |
| Iterator | lowerBound (const T &value) |
Returns an iterator to the first element not less than value. | |
| ConstIterator | lowerBound (const T &value) const |
| Const overload of lowerBound(). | |
| Iterator | upperBound (const T &value) |
Returns an iterator to the first element greater than value. | |
| ConstIterator | upperBound (const T &value) const |
| Const overload of upperBound(). | |
| std::pair< Iterator, bool > | insert (const T &value) |
| Inserts a value into the set. | |
| std::pair< Iterator, bool > | insert (T &&value) |
| Inserts a value into the set (move overload). | |
| bool | remove (const T &value) |
Removes value from the set. | |
| Iterator | remove (Iterator pos) |
Removes the element at pos. | |
| void | clear () noexcept |
| Removes all elements. | |
| void | swap (Set &other) noexcept |
| Swaps contents with another set. | |
| Set | unite (const Set &other) const |
Returns the union of this set and other. | |
| Set | intersect (const Set &other) const |
Returns the intersection of this set and other. | |
| Set | subtract (const Set &other) const |
Returns this set minus other. | |
| List< T > | toList () const |
| Converts the set to a List. | |
| template<typename Func > | |
| void | forEach (Func &&func) const |
Calls func for every element. | |
Friends | |
| bool | operator== (const Set &lhs, const Set &rhs) |
| Returns true if both sets have identical contents. | |
| bool | operator!= (const Set &lhs, const Set &rhs) |
| Returns true if the sets differ. | |
Ordered unique-element container wrapping std::set.
Provides a Qt-inspired API over std::set with consistent naming conventions matching the rest of libpromeki.
| T | Element type (must support operator<). |
Constructs a 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.
|
inlinenoexcept |
Returns a const reverse iterator to the last element.
|
inlinenoexcept |
Returns a const reverse iterator to one before the first element.
Finds value in the set.
| value | The value to search for. |
Calls func for every element.
| Func | Callable with signature void(const T &). |
| func | The function to invoke. |
Inserts a value into the set.
| value | The value to insert. |
Inserts a value into the set (move overload).
| value | The value to insert (moved). |
Returns the intersection of this set and other.
| other | The set to intersect with. |
Returns an iterator to the first element not less than value.
| value | The value to search for. |
Removes value from the set.
| value | The value to remove. |
Removes the element at pos.
| pos | Iterator to the element to remove. |
|
inlinenoexcept |
Returns a mutable reverse iterator to the last element.
|
inlinenoexcept |
Returns a mutable reverse iterator to one before the first element.
Returns this set minus other.
| other | The set to subtract. |
other. Swaps contents with another set.
| other | The set to swap with. |
Returns the union of this set and other.
| other | The set to unite with. |
Returns an iterator to the first element greater than value.
| value | The value to search for. |