![]() |
Open CASCADE Technology Reference Manual 8.0.0
|
High-performance hash set using open addressing with Robin Hood hashing. More...
#include <NCollection_FlatMap.hxx>
Data Structures | |
| class | Iterator |
| Forward iterator for NCollection_FlatMap. More... | |
Public Types | |
| using | key_type = TheKeyType |
| STL-compliant type alias for key type. | |
Public Member Functions | |
| NCollection_FlatMap () | |
| Default constructor. | |
| NCollection_FlatMap (const size_t theNbBuckets) | |
| Constructor with initial capacity hint. | |
| NCollection_FlatMap (const Hasher &theHasher, const size_t theNbBuckets=0) | |
| Constructor with custom hasher (copy). | |
| NCollection_FlatMap (Hasher &&theHasher, const size_t theNbBuckets=0) | |
| Constructor with custom hasher (move). | |
| NCollection_FlatMap (const NCollection_FlatMap &theOther) | |
| Copy constructor. | |
| NCollection_FlatMap (NCollection_FlatMap &&theOther) noexcept | |
| Move constructor. | |
| ~NCollection_FlatMap () | |
| Destructor. | |
| NCollection_FlatMap & | operator= (const NCollection_FlatMap &theOther) |
| Copy assignment. | |
| NCollection_FlatMap & | operator= (NCollection_FlatMap &&theOther) noexcept |
| Move assignment. | |
| size_t | Size () const noexcept |
| Returns number of elements. | |
| bool | IsEmpty () const noexcept |
| Returns true if map is empty. | |
| size_t | Capacity () const noexcept |
| Returns current capacity. | |
| bool | Contains (const TheKeyType &theKey) const |
| Check if key exists. | |
| std::optional< std::reference_wrapper< const TheKeyType > > | Contained (const TheKeyType &theKey) const |
| Contained returns optional const reference to the key in the map. Returns std::nullopt if the key is not found. | |
| const TheKeyType * | Seek (const TheKeyType &theKey) const |
| Seek returns pointer to key in map. Returns NULL if not found. | |
| TheKeyType * | ChangeSeek (const TheKeyType &theKey) |
| ChangeSeek returns modifiable pointer to key in map. Returns NULL if not found. | |
| bool | Add (const TheKeyType &theKey) |
| Add key to set. | |
| bool | Add (TheKeyType &&theKey) |
| Add key to set (move semantics) | |
| const TheKeyType & | Added (const TheKeyType &theKey) |
| Added: add a new key if not yet in the map, and return reference to either newly added or previously existing key. | |
| const TheKeyType & | Added (TheKeyType &&theKey) |
| Added: add a new key if not yet in the map, and return reference to either newly added or previously existing key. | |
| template<typename... Args> | |
| bool | Emplace (Args &&... theArgs) |
| Emplace constructs key in-place; if key exists, overwrites. | |
| template<typename... Args> | |
| const TheKeyType & | Emplaced (Args &&... theArgs) |
| Emplaced constructs key in-place; if key exists, overwrites. | |
| template<typename... Args> | |
| bool | TryEmplace (Args &&... theArgs) |
| TryEmplace constructs key in-place only if not already present. | |
| template<typename... Args> | |
| const TheKeyType & | TryEmplaced (Args &&... theArgs) |
| TryEmplaced constructs key in-place only if not already present. | |
| bool | Remove (const TheKeyType &theKey) |
| Remove key from set. | |
| void | Clear (bool doReleaseMemory=false) |
| Clear all elements. | |
| void | Exchange (NCollection_FlatMap &theOther) noexcept |
| Exchange content with another map. | |
| const Hasher & | GetHasher () const noexcept |
| Returns const reference to the hasher. | |
| void | reserve (size_t theN) |
| Reserve capacity for at least theN elements. | |
| Iterator | begin () const noexcept |
| Iterator | end () const noexcept |
| Iterator | cbegin () const noexcept |
| Iterator | cend () const noexcept |
High-performance hash set using open addressing with Robin Hood hashing.
NCollection_FlatMap is an alternative to NCollection_Map that provides better cache locality and reduced memory allocation overhead by storing all keys inline in a contiguous array.
Key features:
Typical faster usage patterns:
Container-specific implementation notes:
Relative to NCollection_Map:
Limitations:
| TheKeyType | Type of keys |
| Hasher | Hash and equality functor (default: NCollection_DefaultHasher) |
| using NCollection_FlatMap< TheKeyType, Hasher >::key_type = TheKeyType |
STL-compliant type alias for key type.
|
inline |
Default constructor.
|
inlineexplicit |
Constructor with initial capacity hint.
|
inlineexplicit |
Constructor with custom hasher (copy).
| theHasher | custom hasher instance |
| theNbBuckets | initial capacity hint |
|
inlineexplicit |
Constructor with custom hasher (move).
| theHasher | custom hasher instance (moved) |
| theNbBuckets | initial capacity hint |
|
inline |
Copy constructor.
|
inlinenoexcept |
Move constructor.
|
inline |
Destructor.
|
inline |
Add key to set.
|
inline |
Add key to set (move semantics)
|
inline |
Added: add a new key if not yet in the map, and return reference to either newly added or previously existing key.
| theKey | key to add |
|
inline |
Added: add a new key if not yet in the map, and return reference to either newly added or previously existing key.
| theKey | key to add |
|
inlinenoexcept |
|
inlinenoexcept |
Returns current capacity.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
ChangeSeek returns modifiable pointer to key in map. Returns NULL if not found.
|
inline |
Clear all elements.
|
inline |
Contained returns optional const reference to the key in the map. Returns std::nullopt if the key is not found.
|
inline |
Check if key exists.
|
inline |
Emplace constructs key in-place; if key exists, overwrites.
| theArgs | arguments forwarded to key constructor |
|
inline |
Emplaced constructs key in-place; if key exists, overwrites.
| theArgs | arguments forwarded to key constructor |
|
inlinenoexcept |
|
inlinenoexcept |
Exchange content with another map.
|
inlinenoexcept |
Returns const reference to the hasher.
|
inlinenoexcept |
Returns true if map is empty.
|
inline |
Copy assignment.
|
inlinenoexcept |
Move assignment.
|
inline |
Remove key from set.
|
inline |
Reserve capacity for at least theN elements.
|
inline |
Seek returns pointer to key in map. Returns NULL if not found.
|
inlinenoexcept |
Returns number of elements.
|
inline |
TryEmplace constructs key in-place only if not already present.
| theArgs | arguments forwarded to key constructor |
|
inline |
TryEmplaced constructs key in-place only if not already present.
| theArgs | arguments forwarded to key constructor |