ordered-map
|
#include <ordered_set.h>
Public Types | |
using | key_type = typename ht::key_type |
using | value_type = typename ht::value_type |
using | size_type = typename ht::size_type |
using | difference_type = typename ht::difference_type |
using | hasher = typename ht::hasher |
using | key_equal = typename ht::key_equal |
using | allocator_type = typename ht::allocator_type |
using | reference = typename ht::reference |
using | const_reference = typename ht::const_reference |
using | pointer = typename ht::pointer |
using | const_pointer = typename ht::const_pointer |
using | iterator = typename ht::iterator |
using | const_iterator = typename ht::const_iterator |
using | reverse_iterator = typename ht::reverse_iterator |
using | const_reverse_iterator = typename ht::const_reverse_iterator |
using | values_container_type = typename ht::values_container_type |
Public Member Functions | |
ordered_set () | |
ordered_set (size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator()) | |
ordered_set (size_type bucket_count, const Allocator &alloc) | |
ordered_set (size_type bucket_count, const Hash &hash, const Allocator &alloc) | |
ordered_set (const Allocator &alloc) | |
template<class InputIt > | |
ordered_set (InputIt first, InputIt last, size_type bucket_count=ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator()) | |
template<class InputIt > | |
ordered_set (InputIt first, InputIt last, size_type bucket_count, const Allocator &alloc) | |
template<class InputIt > | |
ordered_set (InputIt first, InputIt last, size_type bucket_count, const Hash &hash, const Allocator &alloc) | |
ordered_set (std::initializer_list< value_type > init, size_type bucket_count=ht::DEFAULT_INIT_BUCKETS_SIZE, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator()) | |
ordered_set (std::initializer_list< value_type > init, size_type bucket_count, const Allocator &alloc) | |
ordered_set (std::initializer_list< value_type > init, size_type bucket_count, const Hash &hash, const Allocator &alloc) | |
ordered_set & | operator= (std::initializer_list< value_type > ilist) |
allocator_type | get_allocator () const |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
reverse_iterator | rbegin () noexcept |
const_reverse_iterator | rbegin () const noexcept |
const_reverse_iterator | rcbegin () const noexcept |
reverse_iterator | rend () noexcept |
const_reverse_iterator | rend () const noexcept |
const_reverse_iterator | rcend () const noexcept |
bool | empty () const noexcept |
size_type | size () const noexcept |
size_type | max_size () const noexcept |
void | clear () noexcept |
std::pair< iterator, bool > | insert (const value_type &value) |
std::pair< iterator, bool > | insert (value_type &&value) |
iterator | insert (const_iterator hint, const value_type &value) |
iterator | insert (const_iterator hint, value_type &&value) |
template<class InputIt > | |
void | insert (InputIt first, InputIt last) |
void | insert (std::initializer_list< value_type > ilist) |
template<class... Args> | |
std::pair< iterator, bool > | emplace (Args &&... args) |
template<class... Args> | |
iterator | emplace_hint (const_iterator hint, Args &&... args) |
iterator | erase (iterator pos) |
iterator | erase (const_iterator pos) |
iterator | erase (const_iterator first, const_iterator last) |
size_type | erase (const key_type &key) |
size_type | erase (const key_type &key, std::size_t precalculated_hash) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
size_type | erase (const K &key) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
size_type | erase (const K &key, std::size_t precalculated_hash) |
void | swap (ordered_set &other) |
size_type | count (const Key &key) const |
size_type | count (const Key &key, std::size_t precalculated_hash) const |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
size_type | count (const K &key) const |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
size_type | count (const K &key, std::size_t precalculated_hash) const |
iterator | find (const Key &key) |
iterator | find (const Key &key, std::size_t precalculated_hash) |
const_iterator | find (const Key &key) const |
const_iterator | find (const Key &key, std::size_t precalculated_hash) const |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
iterator | find (const K &key) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
iterator | find (const K &key, std::size_t precalculated_hash) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
const_iterator | find (const K &key) const |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
const_iterator | find (const K &key, std::size_t precalculated_hash) const |
std::pair< iterator, iterator > | equal_range (const Key &key) |
std::pair< iterator, iterator > | equal_range (const Key &key, std::size_t precalculated_hash) |
std::pair< const_iterator, const_iterator > | equal_range (const Key &key) const |
std::pair< const_iterator, const_iterator > | equal_range (const Key &key, std::size_t precalculated_hash) const |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
std::pair< iterator, iterator > | equal_range (const K &key) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
std::pair< iterator, iterator > | equal_range (const K &key, std::size_t precalculated_hash) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
std::pair< const_iterator, const_iterator > | equal_range (const K &key) const |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
std::pair< const_iterator, const_iterator > | equal_range (const K &key, std::size_t precalculated_hash) const |
size_type | bucket_count () const |
size_type | max_bucket_count () const |
float | load_factor () const |
float | max_load_factor () const |
void | max_load_factor (float ml) |
void | rehash (size_type count) |
void | reserve (size_type count) |
hasher | hash_function () const |
key_equal | key_eq () const |
iterator | mutable_iterator (const_iterator pos) |
iterator | nth (size_type index) |
const_iterator | nth (size_type index) const |
const_reference | front () const |
const_reference | back () const |
template<class U = values_container_type, typename std::enable_if< tsl::detail_ordered_hash::is_vector< U >::value >::type * = nullptr> | |
const values_container_type::value_type * | data () const noexcept |
const values_container_type & | values_container () const noexcept |
template<class U = values_container_type, typename std::enable_if< tsl::detail_ordered_hash::is_vector< U >::value >::type * = nullptr> | |
size_type | capacity () const noexcept |
void | shrink_to_fit () |
std::pair< iterator, bool > | insert_at_position (const_iterator pos, const value_type &value) |
std::pair< iterator, bool > | insert_at_position (const_iterator pos, value_type &&value) |
template<class... Args> | |
std::pair< iterator, bool > | emplace_at_position (const_iterator pos, Args &&... args) |
void | pop_back () |
iterator | unordered_erase (iterator pos) |
iterator | unordered_erase (const_iterator pos) |
size_type | unordered_erase (const key_type &key) |
size_type | unordered_erase (const key_type &key, std::size_t precalculated_hash) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
size_type | unordered_erase (const K &key) |
template<class K , class KE = KeyEqual, typename std::enable_if< has_is_transparent< KE >::value >::type * = nullptr> | |
size_type | unordered_erase (const K &key, std::size_t precalculated_hash) |
template<class Serializer > | |
void | serialize (Serializer &serializer) const |
Static Public Member Functions | |
template<class Deserializer > | |
static ordered_set | deserialize (Deserializer &deserializer, bool hash_compatible=false) |
Friends | |
bool | operator== (const ordered_set &lhs, const ordered_set &rhs) |
bool | operator!= (const ordered_set &lhs, const ordered_set &rhs) |
bool | operator< (const ordered_set &lhs, const ordered_set &rhs) |
bool | operator<= (const ordered_set &lhs, const ordered_set &rhs) |
bool | operator> (const ordered_set &lhs, const ordered_set &rhs) |
bool | operator>= (const ordered_set &lhs, const ordered_set &rhs) |
void | swap (ordered_set &lhs, ordered_set &rhs) |
Implementation of an hash set using open adressing with robin hood with backshift delete to resolve collisions.
The particularity of this hash set is that it remembers the order in which the elements were added and provide a way to access the structure which stores these values through the 'values_container()' method. The used container is defined by ValueTypeContainer, by default a std::deque is used (grows faster) but a std::vector may be used. In this case the set provides a 'data()' method which give a direct access to the memory used to store the values (which can be usefull to communicate with C API's).
The Key must be copy constructible and/or move constructible. To use unordered_erase
it also must be swappable.
The behaviour of the hash set is undefinded if the destructor of Key throws an exception.
By default the maximum size of a set is limited to 2^32 - 1 values, if needed this can be changed through the IndexType template parameter. Using an uint64_t
will raise this limit to 2^64 - 1 values but each bucket will use 16 bytes instead of 8 bytes in addition to the space needed to store the values.
Iterators invalidation:
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::allocator_type = typename ht::allocator_type |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::const_iterator = typename ht::const_iterator |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::const_pointer = typename ht::const_pointer |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::const_reference = typename ht::const_reference |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::const_reverse_iterator = typename ht::const_reverse_iterator |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::difference_type = typename ht::difference_type |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::hasher = typename ht::hasher |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::iterator = typename ht::iterator |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::key_equal = typename ht::key_equal |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::key_type = typename ht::key_type |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::pointer = typename ht::pointer |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::reference = typename ht::reference |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::reverse_iterator = typename ht::reverse_iterator |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::size_type = typename ht::size_type |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::value_type = typename ht::value_type |
using tsl::ordered_set< Key, Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType >::values_container_type = typename ht::values_container_type |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return const_reference to the last element. Requires the container to not be empty.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inlinenoexcept |
Only available if ValueTypeContainer is a std::vector. Same as calling 'values_container().data()'.
|
inlinestatic |
Deserialize a previouly serialized set through the deserializer
parameter.
The deserializer
parameter must be a function object that supports the following calls:
template<typename U> U operator()();
where the types std::uint64_t
, float
and Key
must be supported for U.If the deserialized hash set type is hash compatible with the serialized set, the deserialization process can be sped up by setting hash_compatible
to true. To be hash compatible, the Hash and KeyEqual must behave the same way than the ones used on the serialized map. The std::size_t
must also be of the same size as the one on the platform used to serialize the map, the same apply for IndexType
. If these criteria are not met, the behaviour is undefined with hash_compatible
sets to true.
The behaviour is undefined if the type Key
of the ordered_set
is not the same as the type used during serialization.
The implementation leaves binary compatibilty (endianness, IEEE 754 for floats, size of int, ...) of the types it deserializes in the hands of the Deserializer
function object if compatibilty is required.
|
inline |
Due to the way elements are stored, emplace will need to move or copy the key-value once. The method is equivalent to insert(value_type(std::forward<Args>(args)...));
Mainly here for compatibility with the std::unordered_map interface.
|
inline |
Insert the value before pos shifting all the elements on the right of pos (including pos) one position to the right.
Amortized linear time-complexity in the distance between pos and end().
Same as insert_at_position(pos, value_type(std::forward<Args>(args)...), mainly here for coherence.
|
inline |
Due to the way elements are stored, emplace_hint will need to move or copy the key-value once. The method is equivalent to insert(hint, value_type(std::forward<Args>(args)...));
Mainly here for compatibility with the std::unordered_map interface.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
When erasing an element, the insert order will be preserved and no holes will be present in the container returned by 'values_container()'.
The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) average complexity.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup to the value if you already have the hash.
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
|
inline |
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
Return const_reference to the first element. Requires the container to not be empty.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Insert the value before pos shifting all the elements on the right of pos (including pos) one position to the right.
Amortized linear time-complexity in the distance between pos and end().
|
inline |
Insert the value before pos shifting all the elements on the right of pos (including pos) one position to the right.
Amortized linear time-complexity in the distance between pos and end().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
Convert a const_iterator to an iterator.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
Serialize the set through the serializer
parameter.
The serializer
parameter must be a function object that supports the following call:
void operator()(const U& value);
where the types std::uint64_t
, float
and Key
must be supported for U.The implementation leaves binary compatibilty (endianness, IEEE 754 for floats, ...) of the types it serializes in the hands of the Serializer
function object if compatibilty is required.
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order.
If an erasure occurs, the last element of the map will take the place of the erased element.
|
inline |
Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order.
If an erasure occurs, the last element of the map will take the place of the erased element.
|
inline |
Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order.
If an erasure occurs, the last element of the map will take the place of the erased element.
|
inline |
Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order.
If an erasure occurs, the last element of the map will take the place of the erased element.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inline |
Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order.
If an erasure occurs, the last element of the map will take the place of the erased element.
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
|
inline |
Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order.
If an erasure occurs, the last element of the map will take the place of the erased element.
This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. If so, K must be hashable and comparable to Key.
Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same as hash_function()(key). Usefull to speed-up the lookup if you already have the hash.
|
inlinenoexcept |
Return the container in which the values are stored. The values are in the same order as the insertion order and are contiguous in the structure, no holes (size() == values_container().size()).
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |