Ordered unique values stored on Base's heap. More...
#include <StormByte/safe/set.hxx>
Classes | |
| class | iterator |
| Bidirectional cursor. More... | |
| class | const_iterator |
| Read-only bidirectional cursor. More... | |
| class | node_type |
| Owning handle to one extracted Base node. More... | |
| struct | insert_return_type |
| Result of inserting an extracted node. More... | |
Public Types | |
| using | key_type = K |
| Value and lookup type. | |
| using | value_type = K |
| Stored value. | |
| using | key_compare = Compare |
| Ordering. | |
| using | value_compare = Compare |
| Ordering of values. Same as the key ordering. | |
| using | size_type = Size |
| Element count. Size, not std::size_t. | |
| using | difference_type = std::ptrdiff_t |
| Iterator distance type. | |
| using | reference = const K& |
| Read-only value reference. | |
| using | const_reference = const K& |
| Read-only value reference. | |
| using | reverse_iterator = std::reverse_iterator<iterator> |
| Mutable reverse iterator. | |
| using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
| Read-only reverse iterator. | |
| using | insert_result = Pair<iterator, bool> |
| Iterator to the value and whether it was inserted. | |
Public Member Functions | |
| Set () | |
| Construct an empty set. | |
| Set (const Compare &compare) | |
| Construct an empty set with a comparator. | |
| Set (const Set &other) | |
| Copy the values. | |
| Set (Set &&other) | |
| Take the values. | |
| ~Set () | |
| Destroy the values. | |
| Set & | operator= (const Set &other) |
| Copy-assign the values. | |
| Set & | operator= (Set &&other) noexcept |
| Move-assign the values. | |
| Set & | operator= (std::initializer_list< K > values) |
| Replace the contents with an initializer list. | |
| template<class InputIt> | |
| Set (InputIt first, InputIt last) | |
| Construct from an iterator range. | |
| template<class InputIt> | |
| Set (InputIt first, InputIt last, const Compare &compare) | |
| Construct from an iterator range and a comparator. | |
| Set (std::initializer_list< K > values) | |
| Construct from an initializer list. | |
| Set (std::initializer_list< K > values, const Compare &compare) | |
| Construct from an initializer list and a comparator. | |
| key_compare | key_comp () const |
| Return the ordering. | |
| value_compare | value_comp () const |
| Return the ordering. | |
| iterator | begin () noexcept |
| Return an iterator to the first value. | |
| const_iterator | begin () const noexcept |
| Return an iterator to the first value. | |
| const_iterator | cbegin () const noexcept |
| Return an iterator to the first value. | |
| iterator | end () noexcept |
| Return the past-the-end iterator. | |
| const_iterator | end () const noexcept |
| Return the past-the-end iterator. | |
| const_iterator | cend () const noexcept |
| Return the past-the-end iterator. | |
| reverse_iterator | rbegin () noexcept |
| Return a reverse iterator to the last value. | |
| const_reverse_iterator | rbegin () const noexcept |
| Return a reverse iterator to the last value. | |
| const_reverse_iterator | crbegin () const noexcept |
| Return a reverse iterator to the last value. | |
| reverse_iterator | rend () noexcept |
| Return the past-the-start reverse iterator. | |
| const_reverse_iterator | rend () const noexcept |
| Return the past-the-start reverse iterator. | |
| const_reverse_iterator | crend () const noexcept |
| Return the past-the-start reverse iterator. | |
| bool | empty () const noexcept |
| Test whether the set has no values. | |
| size_type | size () const noexcept |
| Return the number of values. | |
| size_type | max_size () const noexcept |
| Return the maximum number of values. | |
| void | clear () noexcept |
| Destroy every value. | |
| insert_result | insert (const K &value) |
| Insert a value if it is absent. | |
| insert_result | insert (K &&value) |
| Insert a value if it is absent. | |
| iterator | insert (const_iterator hint, const K &value) |
Insert a value, using hint when the neighbours confirm it. | |
| iterator | insert (const_iterator hint, K &&value) |
Insert a value, using hint when the neighbours confirm it. | |
| template<class InputIt> | |
| void | insert (InputIt first, InputIt last) |
| Insert every value in [first, last). | |
| void | insert (std::initializer_list< K > values) |
| Insert every value of an initializer list. | |
| template<std::ranges::input_range R> requires std::convertible_to<std::ranges::range_reference_t<R>, value_type> | |
| STORMBYTE_FORCE_INLINE void | insert_range (R &&range) |
Insert a copy of range. | |
| template<class... Args> | |
| insert_result | emplace (Args &&... args) |
| Construct a value in a new node if it is absent. | |
| template<class... Args> | |
| iterator | emplace_hint (const_iterator hint, Args &&... args) |
Construct a value, using hint when the neighbours confirm it. | |
| insert_return_type | insert (node_type &&handle) |
| Insert an extracted node if its value is absent. | |
| iterator | insert (const_iterator hint, node_type &&handle) |
Insert an extracted node, using hint when the neighbours confirm it. | |
| node_type | extract (const_iterator position) |
Unlink the value at position and return that node. | |
| node_type | extract (const K &value) |
Unlink value and return that node. | |
| template<class OtherCompare> | |
| void | merge (Set< K, OtherCompare > &source) |
Take unique values from source. | |
| iterator | erase (iterator position) noexcept |
| Erase the value at an iterator. | |
| iterator | erase (const_iterator position) noexcept |
| Erase the value at a read-only iterator. | |
| iterator | erase (const_iterator first, const_iterator last) noexcept |
| Erase [first, last). | |
| size_type | erase (const K &value) noexcept |
| Erase a value. | |
| void | swap (Set &other) noexcept |
| Exchange values and comparators. | |
| iterator | find (const K &value) |
| Find a value. | |
| const_iterator | find (const K &value) const |
| Find a value. | |
| size_type | count (const K &value) const |
| Count matching values. | |
| bool | contains (const K &value) const |
| Test whether a value is present. | |
| iterator | lower_bound (const K &value) |
Return the first value not less than value. | |
| const_iterator | lower_bound (const K &value) const |
Return the first value not less than value. | |
| iterator | upper_bound (const K &value) |
Return the first value greater than value. | |
| const_iterator | upper_bound (const K &value) const |
Return the first value greater than value. | |
| Pair< iterator, iterator > | equal_range (const K &value) |
Return the range of values equal to value. | |
| Pair< const_iterator, const_iterator > | equal_range (const K &value) const |
Return the range of values equal to value. | |
| bool | operator== (const Set &other) const |
| Compare lexicographically. | |
| bool | operator!= (const Set &other) const |
| Compare lexicographically. | |
| bool | operator< (const Set &other) const |
| Compare lexicographically. | |
| bool | operator<= (const Set &other) const |
| Compare lexicographically. | |
| bool | operator> (const Set &other) const |
| Compare lexicographically. | |
| bool | operator>= (const Set &other) const |
| Compare lexicographically. | |
| STORMBYTE_FORCE_INLINE | operator std::set< K, Compare > () const |
| Copy the values into caller-owned STL storage. | |
Ordered unique values stored on Base's heap.
| K | Safe value type. |
| Compare | Strict weak ordering. A stateless comparator does not allocate. A stateful one is stored in the set and must itself be Safe. |
The tree is the same Base-heap tree as Map. Iterators yield the key, not a pair. node_type owns a Base node. It is not std::set::node_type. There is no allocator.
| using StormByte::Safe::Set< K, Compare >::const_reference = const K& |
Read-only value reference.
| using StormByte::Safe::Set< K, Compare >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Read-only reverse iterator.
| using StormByte::Safe::Set< K, Compare >::difference_type = std::ptrdiff_t |
Iterator distance type.
| using StormByte::Safe::Set< K, Compare >::insert_result = Pair<iterator, bool> |
Iterator to the value and whether it was inserted.
| using StormByte::Safe::Set< K, Compare >::key_compare = Compare |
Ordering.
| using StormByte::Safe::Set< K, Compare >::key_type = K |
Value and lookup type.
| using StormByte::Safe::Set< K, Compare >::reference = const K& |
Read-only value reference.
| using StormByte::Safe::Set< K, Compare >::reverse_iterator = std::reverse_iterator<iterator> |
Mutable reverse iterator.
| using StormByte::Safe::Set< K, Compare >::size_type = Size |
Element count. Size, not std::size_t.
| using StormByte::Safe::Set< K, Compare >::value_compare = Compare |
Ordering of values. Same as the key ordering.
| using StormByte::Safe::Set< K, Compare >::value_type = K |
Stored value.
| StormByte::Safe::Set< K, Compare >::Set | ( | ) |
Construct an empty set.
|
explicit |
Construct an empty set with a comparator.
| compare | Value ordering. |
| StormByte::Safe::Set< K, Compare >::Set | ( | const Set< K, Compare > & | other | ) |
| StormByte::Safe::Set< K, Compare >::Set | ( | Set< K, Compare > && | other | ) |
Take the values.
other is left empty.
| other | Source. |
| StormByte::Safe::Set< K, Compare >::~Set | ( | ) |
Destroy the values.
| StormByte::Safe::Set< K, Compare >::Set | ( | InputIt | first, |
| InputIt | last ) |
Construct from an iterator range.
| InputIt | Input iterator of values. |
| first | Start. |
| last | End. |
| AllocationError | A node could not be allocated. |
| StormByte::Safe::Set< K, Compare >::Set | ( | InputIt | first, |
| InputIt | last, | ||
| const Compare & | compare ) |
Construct from an iterator range and a comparator.
| InputIt | Input iterator of values. |
| first | Start. |
| last | End. |
| compare | Value ordering. |
| AllocationError | A node could not be allocated. |
| StormByte::Safe::Set< K, Compare >::Set | ( | std::initializer_list< K > | values | ) |
Construct from an initializer list.
| values | Values. Duplicates are dropped. |
| AllocationError | A node could not be allocated. |
| StormByte::Safe::Set< K, Compare >::Set | ( | std::initializer_list< K > | values, |
| const Compare & | compare ) |
Construct from an initializer list and a comparator.
| values | Values. Duplicates are dropped. |
| compare | Value ordering. |
| AllocationError | A node could not be allocated. |
|
noexcept |
Return an iterator to the first value.
|
noexcept |
Return an iterator to the first value.
|
noexcept |
Return an iterator to the first value.
|
noexcept |
Return the past-the-end iterator.
|
noexcept |
Destroy every value.
| bool StormByte::Safe::Set< K, Compare >::contains | ( | const K & | value | ) | const |
| size_type StormByte::Safe::Set< K, Compare >::count | ( | const K & | value | ) | const |
Count matching values.
| value | Lookup value. |
|
noexcept |
Return a reverse iterator to the last value.
|
noexcept |
Return the past-the-start reverse iterator.
| insert_result StormByte::Safe::Set< K, Compare >::emplace | ( | Args &&... | args | ) |
Construct a value in a new node if it is absent.
| Args | Value constructor argument types. |
| args | Arguments forwarded to K. |
| AllocationError | The node could not be allocated. |
| iterator StormByte::Safe::Set< K, Compare >::emplace_hint | ( | const_iterator | hint, |
| Args &&... | args ) |
Construct a value, using hint when the neighbours confirm it.
| Args | Value constructor argument types. |
| hint | Suggested position. |
| args | Arguments forwarded to K. |
| AllocationError | The node could not be allocated. |
|
noexcept |
Test whether the set has no values.
|
noexcept |
Return the past-the-end iterator.
|
noexcept |
Return the past-the-end iterator.
| Pair< iterator, iterator > StormByte::Safe::Set< K, Compare >::equal_range | ( | const K & | value | ) |
Return the range of values equal to value.
| value | Lookup value. |
| Pair< const_iterator, const_iterator > StormByte::Safe::Set< K, Compare >::equal_range | ( | const K & | value | ) | const |
Return the range of values equal to value.
| value | Lookup value. |
|
noexcept |
Erase a value.
| value | Lookup value. |
|
noexcept |
Erase [first, last).
| first | First value to erase. |
| last | End of the range. |
|
noexcept |
Erase the value at a read-only iterator.
| position | Value to erase. |
|
noexcept |
Erase the value at an iterator.
| position | Value to erase. |
| node_type StormByte::Safe::Set< K, Compare >::extract | ( | const K & | value | ) |
Unlink value and return that node.
| value | Lookup value. |
| node_type StormByte::Safe::Set< K, Compare >::extract | ( | const_iterator | position | ) |
Unlink the value at position and return that node.
| position | Value to extract. |
position is end. | iterator StormByte::Safe::Set< K, Compare >::find | ( | const K & | value | ) |
Find a value.
| value | Lookup value. |
| const_iterator StormByte::Safe::Set< K, Compare >::find | ( | const K & | value | ) | const |
Find a value.
| value | Lookup value. |
| insert_result StormByte::Safe::Set< K, Compare >::insert | ( | const K & | value | ) |
Insert a value if it is absent.
| value | Value to copy. |
| AllocationError | The node could not be allocated. |
| iterator StormByte::Safe::Set< K, Compare >::insert | ( | const_iterator | hint, |
| const K & | value ) |
Insert a value, using hint when the neighbours confirm it.
| hint | Suggested position. |
| value | Value to copy. |
| AllocationError | The node could not be allocated. |
| iterator StormByte::Safe::Set< K, Compare >::insert | ( | const_iterator | hint, |
| K && | value ) |
Insert a value, using hint when the neighbours confirm it.
| hint | Suggested position. |
| value | Value to move. |
| AllocationError | The node could not be allocated. |
| iterator StormByte::Safe::Set< K, Compare >::insert | ( | const_iterator | hint, |
| node_type && | handle ) |
Insert an extracted node, using hint when the neighbours confirm it.
| hint | Suggested position. |
| handle | Node from a set with this ordering. Emptied when inserted. |
handle was empty. | void StormByte::Safe::Set< K, Compare >::insert | ( | InputIt | first, |
| InputIt | last ) |
Insert every value in [first, last).
| InputIt | Input iterator of values. |
| first | Start. |
| last | End. |
| AllocationError | A node could not be allocated. |
| insert_result StormByte::Safe::Set< K, Compare >::insert | ( | K && | value | ) |
Insert a value if it is absent.
| value | Value to move. |
| AllocationError | The node could not be allocated. |
| insert_return_type StormByte::Safe::Set< K, Compare >::insert | ( | node_type && | handle | ) |
Insert an extracted node if its value is absent.
The same node is linked.
| handle | Node from a set with this ordering. Emptied when inserted. |
| void StormByte::Safe::Set< K, Compare >::insert | ( | std::initializer_list< K > | values | ) |
Insert every value of an initializer list.
| values | Values. |
| AllocationError | A node could not be allocated. |
|
inline |
Insert a copy of range.
| R | Input range of values. |
| range | Source. Instantiated in the caller. |
| AllocationError | A node could not be allocated. |
| key_compare StormByte::Safe::Set< K, Compare >::key_comp | ( | ) | const |
Return the ordering.
| iterator StormByte::Safe::Set< K, Compare >::lower_bound | ( | const K & | value | ) |
Return the first value not less than value.
| value | Lookup value. |
| const_iterator StormByte::Safe::Set< K, Compare >::lower_bound | ( | const K & | value | ) | const |
Return the first value not less than value.
| value | Lookup value. |
|
noexcept |
Return the maximum number of values.
| void StormByte::Safe::Set< K, Compare >::merge | ( | Set< K, OtherCompare > & | source | ) |
Take unique values from source.
| OtherCompare | Source ordering. |
| source | Set to drain. The same ordering transfers the node. A different ordering copies the key. Values already present stay in source. |
| AllocationError | A copied node could not be allocated. |
|
inlineexplicit |
Copy the values into caller-owned STL storage.
| bool StormByte::Safe::Set< K, Compare >::operator!= | ( | const Set< K, Compare > & | other | ) | const |
Compare lexicographically.
| other | Other set. |
| bool StormByte::Safe::Set< K, Compare >::operator< | ( | const Set< K, Compare > & | other | ) | const |
Compare lexicographically.
| other | Other set. |
other. | bool StormByte::Safe::Set< K, Compare >::operator<= | ( | const Set< K, Compare > & | other | ) | const |
Compare lexicographically.
| other | Other set. |
other. | Set & StormByte::Safe::Set< K, Compare >::operator= | ( | const Set< K, Compare > & | other | ) |
Copy-assign the values.
| other | Source. |
| AllocationError | A node could not be allocated. |
|
noexcept |
Move-assign the values.
other is left empty.
| other | Source. |
| Set & StormByte::Safe::Set< K, Compare >::operator= | ( | std::initializer_list< K > | values | ) |
Replace the contents with an initializer list.
| values | Values. Duplicates are dropped. |
| AllocationError | A node could not be allocated. |
| bool StormByte::Safe::Set< K, Compare >::operator== | ( | const Set< K, Compare > & | other | ) | const |
Compare lexicographically.
| other | Other set. |
other. | bool StormByte::Safe::Set< K, Compare >::operator> | ( | const Set< K, Compare > & | other | ) | const |
Compare lexicographically.
| other | Other set. |
other. | bool StormByte::Safe::Set< K, Compare >::operator>= | ( | const Set< K, Compare > & | other | ) | const |
Compare lexicographically.
| other | Other set. |
other.
|
noexcept |
Return a reverse iterator to the last value.
|
noexcept |
Return a reverse iterator to the last value.
|
noexcept |
Return the past-the-start reverse iterator.
|
noexcept |
Return the past-the-start reverse iterator.
|
noexcept |
Return the number of values.
|
noexcept |
Exchange values and comparators.
| other | Other set. |
| iterator StormByte::Safe::Set< K, Compare >::upper_bound | ( | const K & | value | ) |
Return the first value greater than value.
| value | Lookup value. |
| const_iterator StormByte::Safe::Set< K, Compare >::upper_bound | ( | const K & | value | ) | const |
Return the first value greater than value.
| value | Lookup value. |
| value_compare StormByte::Safe::Set< K, Compare >::value_comp | ( | ) | const |
Return the ordering.