|
| | 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.
|
| void | Reserve (const 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 |
template<class TheKeyType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
class NCollection_FlatMap< TheKeyType, Hasher >
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:
- Open addressing with linear probing (better cache locality)
- Robin Hood hashing (reduces probe sequence variance)
- Power-of-2 sizing for fast modulo operations
- No per-element allocations
Typical faster usage patterns:
- POD or small key types
- Performance-critical code paths
- Lookup-heavy workloads (Contains()/Seek())
- Full traversal / iteration-heavy workloads
- Stable-size maps with Reserve() called once before bulk insert
Container-specific implementation notes:
- Remove() keeps probe clusters consistent using backward-shift compaction.
Relative to NCollection_Map:
- Add()/Remove() can be faster in many workloads thanks to contiguous storage and no per-element node allocation.
- Iteration is often faster due to contiguous slot scanning and reduced pointer chasing.
Limitations:
- Keys must be movable
- Higher memory usage at low load factors
- Iteration order is not insertion order
- Probe distance grows with collisions (bounded by table capacity)
- Note
- This class is NOT thread-safe. External synchronization is required for concurrent access from multiple threads.
- Template Parameters
-