Confluent Sets and Maps
|
Public Types | |
typedef T | key_type |
typedef T | value_type |
typedef set_provider< T, Compare, Hash, Equal > | provider_type |
typedef std::shared_ptr< provider_type > | provider_ptr |
typedef confluent::iterator< traits > | iterator |
typedef std::reverse_iterator< iterator > | reverse_iterator |
Public Member Functions | |
set (provider_ptr provider=provider_type::default_provider()) | |
template<class InputIterator > | |
set (InputIterator first, InputIterator last, provider_ptr provider=provider_type::default_provider()) | |
set (std::initializer_list< value_type > ilist, provider_ptr provider=provider_type::default_provider()) | |
set (iterator first, iterator last) | |
set (const set &other) | |
set (set &&other) | |
size_t | insert (const value_type &value) |
template<class InputIterator > | |
size_t | insert (InputIterator first, InputIterator last) |
size_t | insert (std::initializer_list< value_type > ilist) |
size_t | insert (const set &other) |
size_t | erase (const key_type &key) |
size_t | erase (iterator first, iterator last) |
size_t | erase (const set &other) |
size_t | retain (iterator first, iterator last) |
size_t | retain (const set &other) |
void | clear () |
void | swap (set &other) |
set & | operator= (const set &other) |
set & | operator= (set &&other) |
set & | operator= (std::initializer_list< value_type > ilist) |
set | operator| (const set &rhs) const |
set & | operator|= (const set &rhs) |
set | operator& (const set &rhs) const |
set & | operator&= (const set &rhs) |
set | operator- (const set &rhs) const |
set & | operator-= (const set &rhs) |
set | operator^ (const set &rhs) const |
set & | operator^= (const set &rhs) |
iterator | begin () const |
iterator | end () const |
iterator | cbegin () const |
iterator | cend () const |
reverse_iterator | rbegin () const |
reverse_iterator | rend () const |
iterator | find (const key_type &key) const |
iterator | lower_bound (const key_type &key) const |
iterator | upper_bound (const key_type &key) const |
std::pair< iterator, iterator > | equal_range (const key_type &key) const |
const value_type & | at_index (size_t k) const |
size_t | count (const key_type &key) const |
bool | includes (const set &other) const |
const provider_ptr & | provider () const |
bool | empty () const |
size_t | size () const |
size_t | hash () const |
bool | operator== (const set &rhs) const |
bool | operator!= (const set &rhs) const |
The class confluent::set is a sorted associative container whose instances share nodes with other sets and maps using the same set_provider.
Cloning sets and testing sets for equal content run in constant time. Merge operations such as set union, set intersection and set difference perform at optimal cost not only when one of the input sets is smaller than the other, but also when the number of elements that differ between the inputs set is small.
Contained elements must be comparable, hashable and copy-constructible and documented performance is based on that such operations are constant in time and memory and that hash collisions are rare.
|
inline |
Creates a new set.
provider | set_provider to use for this set (optional) |
Complexity: Constant in time and memory.
|
inline |
Creates a new set from a range of elements.
first | range start |
last | range end |
provider | set_provider to use for this set (optional) |
Complexity: O(n log n) expected time on random input. O(n) on presorted input. O(n) in memory.
|
inline |
Creates a new set from an initializer_list.
ilist | the list of elements to include in the created set |
provider | set_provider to use for this set (optional) |
Complexity: O(n log n) expected time on random input. O(n) on presorted input. O(n) in memory.
|
inline |
Creates a new set from a range in another set.
The created set will use the same set_provider as the source set.
first | range start |
last | range end |
Complexity: O(log n) expected time and memory.
|
inline |
Creates a new set as a copy of another set.
The created set will use the same set_provider as the source set.
other | other set |
Complexity: Constant in time and memory.
|
inline |
Creates a new set by moving content from another set.
The created set will use the same set_provider as the source set.
Result is undefined if the other set is used after content has been moved.
other | other set |
Complexity: Constant in time and memory.
|
inline |
Inserts an element into this set.
The new element is inserted if it is not contained before.
value | element to insert |
Complexity: O(log n) expected time and memory.
|
inline |
Inserts a range of elements into this set.
New element are inserted if they are not contained before.
first | range start |
last | range end |
Complexity: Same cost as first creating a set from the given range and then inserting the created set into this set.
|
inline |
Inserts elements from an initializer_list into this set.
New element are inserted if they are not contained before.
ilist | the list of elements to insert |
Complexity: Same cost as first creating a set from the given initializer_list and then inserting the created set into this set.
|
inline |
Inserts elements in another set into this set.
New element are inserted if they are not contained before.
Result is undefined if not both sets are using the same set_provider.
other | other set to insert elements from |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
|
inline |
Erases an element from this set.
The given element is erased if contained in the set.
key | element to erase |
Complexity: O(log n) expected time and memory.
|
inline |
Erases a range of elements from this set.
The given range must be a range in this set.
first | range start |
last | range end |
Complexity: O(log n) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Erases elements in another set from this set.
After the operation this set will contain the set difference, i.e. all elements that were present in this set but not in the other set.
Result is undefined if not both sets are using the same set_provider.
other | other set to erase elements from |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Retains a range of elements.
The given range must be a range in this set.
After the operation this set will contain the elements in the range.
first | range start |
last | range end |
Complexity: O(log n) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Retains elements that are contained in another set.
After the operation this set will contain the set intersection, i.e. all elements that were present in this set and also in the other set.
Result is undefined if not both sets are using the same set_provider.
other | other set whose elements should be retained |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Erases all elements in this set.
Complexity: Constant in time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Swaps the content of this set with the content of another set.
Complexity: Constant in time and memory.
|
inline |
Replaces the content of this set with the content of another set.
After the operation this set will use the same provider as the other set.
Complexity: Constant in time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Replaces the content of this set with the content of another set.
After the operation this set will use the same provider as the other set used before the operation.
Result is undefined if the other set is used after content has been moved.
Complexity: Constant in time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Replaces the content of this set with elements from an initializer_list.
ilist | the list of elements to assign |
Complexity: O(n log n) expected time on random input. O(n) on presorted input. O(n) in memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Returns the union of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
|
inline |
Replaces the content of this set with the union of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
|
inline |
Returns the intersection of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Replaces the content of this set with the intersection of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Returns the difference of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Replaces the content of this set with the difference of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Returns the symmetric difference of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Replaces the content of this set with the symmetric difference of this set and another set.
Result is undefined if not both sets are using the same set_provider.
rhs | other set to merge with this set |
Let n be the size of the larger set. Let m be the size of the smaller set. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: This operation might cause destruction of unused nodes, but the cost of destructing nodes is always covered by the cost of creating them.
|
inline |
Returns an iterator to the beginning of this set.
|
inline |
Returns an iterator to the end of this set.
|
inline |
Returns an iterator to the beginning of this set.
|
inline |
Returns an iterator to the end of this set.
|
inline |
Returns a reverse iterator to the beginning of this set.
|
inline |
Returns a reverse iterator to the end of this set.
|
inline |
Finds an element with a given key.
key | key to search for |
Complexity: O(log n) expected time.
|
inline |
Returns an iterator to the first element not less than a given key.
key | key to search for |
Complexity: O(log n) expected time.
|
inline |
Returns an iterator to the first element greater than a given key.
key | key to search for |
Complexity: O(log n) expected time.
|
inline |
Returns range of elements matching a given key.
r = s.equal_range(key);
is equivalent to
r = { s.lower_bound(key), s.upper_bound(key)};
Complexity: O(log n) expected time.
|
inline |
Finds an element at a given index.
k | the index of the wanted element |
Complexity: O(log n) expected time.
|
inline |
Returns the number of elements matching a given key
key | key to search for |
Complexity: O(log n) expected time.
|
inline |
Tests if this set includes the elements in another set.
Result is undefined if not both sets are using the same set_provider.
other | set to test if its elements are included in this set |
Let n be the size of this set. Let m be the size of the other. Let d be the size of the difference between this set and the other set.
Complexity: O(min(m * log(n/m), d * log(n/d))) expected time and memory.
Note: The operation will return directly if m > n.
|
inline |
Returns a shared pointer to the set_provider used by this set.
|
inline |
Tests if this set is empty.
Complexity: Constant in time.
|
inline |
Returns the number of elements in this set.
Complexity: Constant in time.
|
inline |
Returns the combined hash value of all elements in this set.
Complexity: Constant in time.
|
inline |
Tests if this set contains the same elements as another set.
Result is undefined if not both sets are using the same set_provider.
Complexity: Constant in time.
|
inline |
Tests if this set does not contain the same elements as another set.
Result is undefined if not both sets are using the same set_provider.
Complexity: Constant in time.