|
| iterator | begin () const noexcept |
| | Returns an iterator pointing to the first element in the map.
|
| |
| iterator | end () const noexcept |
| | Returns an iterator referring to the past-the-end element in the map.
|
| |
| const_iterator | cbegin () const noexcept |
| | Returns a const iterator pointing to the first element in the map.
|
| |
| const_iterator | cend () const noexcept |
| | Returns a const iterator referring to the past-the-end element in the map.
|
| |
| ItemsView | Items () |
| | Returns a view for key-value pair iteration. Usage: for (auto [aKey, aValue] : aMap.Items())
|
| |
| ConstItemsView | Items () const |
| | Returns a const view for key-value pair iteration. Usage: for (const auto& [aKey, aValue] : aMap.Items())
|
| |
| | NCollection_OrderedDataMap () |
| | Empty Constructor.
|
| |
| | NCollection_OrderedDataMap (const size_t theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor.
|
| |
| | NCollection_OrderedDataMap (const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor (legacy int-taking).
|
| |
| | NCollection_OrderedDataMap (const Hasher &theHasher, const size_t theNbBuckets=1, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (copy).
|
| |
| | NCollection_OrderedDataMap (const Hasher &theHasher, const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (copy, legacy int-taking).
|
| |
| | NCollection_OrderedDataMap (Hasher &&theHasher, const size_t theNbBuckets=1, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (move).
|
| |
| | NCollection_OrderedDataMap (Hasher &&theHasher, const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (move, legacy int-taking).
|
| |
| | NCollection_OrderedDataMap (const NCollection_OrderedDataMap &theOther) |
| | Copy constructor.
|
| |
| | NCollection_OrderedDataMap (NCollection_OrderedDataMap &&theOther) noexcept |
| | Move constructor.
|
| |
| void | Exchange (NCollection_OrderedDataMap &theOther) noexcept |
| | Exchange the content of two maps without re-allocations. Notice that allocators will be swapped as well!
|
| |
| const Hasher & | GetHasher () const noexcept |
| | Returns const reference to the hasher.
|
| |
| NCollection_OrderedDataMap & | Assign (const NCollection_OrderedDataMap &theOther) |
| | Assignment. This method does not change the internal allocator.
|
| |
| NCollection_OrderedDataMap & | operator= (const NCollection_OrderedDataMap &theOther) |
| | Assignment operator.
|
| |
| NCollection_OrderedDataMap & | operator= (NCollection_OrderedDataMap &&theOther) noexcept |
| | Move operator.
|
| |
| void | ReSize (const size_t N) |
| | ReSize.
|
| |
| void | ReSize (const int N) |
| |
| bool | Bind (const TheKeyType &theKey, const TheItemType &theItem) |
| | Bind binds Item to Key in map.
|
| |
| bool | Bind (TheKeyType &&theKey, const TheItemType &theItem) |
| | Bind binds Item to Key in map.
|
| |
| bool | Bind (const TheKeyType &theKey, TheItemType &&theItem) |
| | Bind binds Item to Key in map.
|
| |
| bool | Bind (TheKeyType &&theKey, TheItemType &&theItem) |
| | Bind binds Item to Key in map.
|
| |
| TheItemType * | Bound (const TheKeyType &theKey, const TheItemType &theItem) |
| | Bound binds Item to Key in map.
|
| |
| TheItemType * | Bound (TheKeyType &&theKey, const TheItemType &theItem) |
| | Bound binds Item to Key in map.
|
| |
| TheItemType * | Bound (const TheKeyType &theKey, TheItemType &&theItem) |
| | Bound binds Item to Key in map.
|
| |
| TheItemType * | Bound (TheKeyType &&theKey, TheItemType &&theItem) |
| | Bound binds Item to Key in map.
|
| |
| bool | TryBind (const TheKeyType &theKey, const TheItemType &theItem) |
| | TryBind binds Item to Key in map only if Key is not yet bound.
|
| |
| bool | TryBind (TheKeyType &&theKey, const TheItemType &theItem) |
| | TryBind binds Item to Key in map only if Key is not yet bound.
|
| |
| bool | TryBind (const TheKeyType &theKey, TheItemType &&theItem) |
| | TryBind binds Item to Key in map only if Key is not yet bound.
|
| |
| bool | TryBind (TheKeyType &&theKey, TheItemType &&theItem) |
| | TryBind binds Item to Key in map only if Key is not yet bound.
|
| |
| TheItemType & | TryBound (const TheKeyType &theKey, const TheItemType &theItem) |
| | TryBound binds Item to Key in map only if Key is not yet bound.
|
| |
| TheItemType & | TryBound (TheKeyType &&theKey, const TheItemType &theItem) |
| | TryBound binds Item to Key in map only if Key is not yet bound.
|
| |
| TheItemType & | TryBound (const TheKeyType &theKey, TheItemType &&theItem) |
| | TryBound binds Item to Key in map only if Key is not yet bound.
|
| |
| TheItemType & | TryBound (TheKeyType &&theKey, TheItemType &&theItem) |
| | TryBound binds Item to Key in map only if Key is not yet bound.
|
| |
| template<typename K , typename... Args> |
| bool | Emplace (K &&theKey, Args &&... theArgs) |
| | Emplace constructs value in-place; if key exists, destroys and reconstructs value.
|
| |
| template<typename K , typename... Args> |
| TheItemType & | Emplaced (K &&theKey, Args &&... theArgs) |
| | Emplaced constructs value in-place; if key exists, destroys and reconstructs value.
|
| |
| template<typename K , typename... Args> |
| bool | TryEmplace (K &&theKey, Args &&... theArgs) |
| | TryEmplace constructs value in-place only if key not already bound.
|
| |
| template<typename K , typename... Args> |
| TheItemType & | TryEmplaced (K &&theKey, Args &&... theArgs) |
| | TryEmplaced constructs value in-place only if key not already bound.
|
| |
| bool | IsBound (const TheKeyType &theKey) const |
| | IsBound.
|
| |
| std::optional< std::pair< std::reference_wrapper< const TheKeyType >, std::reference_wrapper< const TheItemType > > > | Contained (const TheKeyType &theKey) const |
| | Contained returns optional pair of const references to key and value. Returns std::nullopt if the key is not found.
|
| |
| std::optional< std::pair< std::reference_wrapper< const TheKeyType >, std::reference_wrapper< TheItemType > > > | Contained (const TheKeyType &theKey) |
| | Contained returns optional pair of const key reference and mutable value reference. Returns std::nullopt if the key is not found.
|
| |
| bool | UnBind (const TheKeyType &theKey) |
| | UnBind removes Item Key pair from map.
|
| |
| const TheItemType * | Seek (const TheKeyType &theKey) const |
| | Seek returns pointer to Item by Key. Returns NULL if Key was not bound.
|
| |
| const TheItemType & | Find (const TheKeyType &theKey) const |
| | Find returns the Item for Key. Raises if Key was not bound.
|
| |
| bool | Find (const TheKeyType &theKey, TheItemType &theValue) const |
| | Find Item for key with copying.
|
| |
| const TheItemType & | operator() (const TheKeyType &theKey) const |
| | operator ()
|
| |
| TheItemType * | ChangeSeek (const TheKeyType &theKey) |
| | ChangeSeek returns modifiable pointer to Item by Key. Returns NULL if Key was not bound.
|
| |
| TheItemType & | ChangeFind (const TheKeyType &theKey) |
| | ChangeFind returns modifiable Item by Key. Raises if Key was not bound.
|
| |
| TheItemType & | operator() (const TheKeyType &theKey) |
| | operator ()
|
| |
| void | Clear (const bool doReleaseMemory=false) |
| | Clear data. If doReleaseMemory is false then the table of buckets is not released and will be reused.
|
| |
| void | Clear (const occ::handle< NCollection_BaseAllocator > &theAllocator) |
| | Clear data and reset allocator.
|
| |
| | ~NCollection_OrderedDataMap () override |
| | Destructor.
|
| |
| const TheKeyType & | First () const |
| | Returns the first key in insertion order.
|
| |
| const TheKeyType & | Last () const |
| | Returns the last key in insertion order.
|
| |
| const TheItemType & | FirstValue () const |
| | Returns the first value in insertion order.
|
| |
| const TheItemType & | LastValue () const |
| | Returns the last value in insertion order.
|
| |
| TheItemType & | ChangeFirstValue () |
| | Returns modifiable first value in insertion order.
|
| |
| TheItemType & | ChangeLastValue () |
| | Returns modifiable last value in insertion order.
|
| |
| size_t | NbBuckets () const noexcept |
| | NbBuckets.
|
| |
| int | Extent () const noexcept |
| | Extent (number of elements, legacy int-returning API).
|
| |
| int | Length () const noexcept |
| | Length - number of elements (legacy int-returning API, synonym of Extent()).
|
| |
| size_t | Size () const noexcept |
| | Size - number of elements.
|
| |
| bool | IsEmpty () const noexcept |
| | IsEmpty.
|
| |
| const occ::handle< NCollection_BaseAllocator > & | Allocator () const noexcept |
| | Returns attached allocator.
|
| |
|
| bool | lookup (const TheKeyType &theKey, OrderedDataMapNode *&theNode) const |
| | Lookup for particular key in map.
|
| |
| bool | lookup (const TheKeyType &theKey, OrderedDataMapNode *&theNode, size_t &theHash) const |
| | Lookup for particular key in map.
|
| |
| bool | IsEqual (const TheKeyType &theKey1, const TheKeyType &theKey2) const |
| |
| size_t | HashCode (const TheKeyType &theKey, const size_t theUpperBound) const |
| |
| void | appendToList (OrderedDataMapNode *theNode) |
| | Append a node to the tail of the insertion-order linked list.
|
| |
| void | unlinkFromList (OrderedDataMapNode *theNode) |
| | Unlink a node from the insertion-order linked list.
|
| |
| template<typename K , bool IsTry, bool ReturnRef, typename... Args> |
| auto | emplaceImpl (K &&theKey, std::bool_constant< IsTry >, std::bool_constant< ReturnRef >, Args &&... theArgs) -> std::conditional_t< ReturnRef, TheItemType &, bool > |
| | Implementation helper for Bind/TryBind/Bound/TryBound/Emplace/TryEmplace/Emplaced/TryEmplaced.
|
| |
| | NCollection_BaseMap (const size_t theNbBuckets, const bool single, const occ::handle< NCollection_BaseAllocator > &theAllocator) |
| | Constructor.
|
| |
| | NCollection_BaseMap (NCollection_BaseMap &&theOther) noexcept |
| | Move Constructor.
|
| |
| virtual | ~NCollection_BaseMap ()=default |
| | Destructor.
|
| |
| bool | BeginResize (const size_t theExtent, size_t &theNewBuckets, NCollection_ListNode **&data1, NCollection_ListNode **&data2) const |
| | BeginResize.
|
| |
| void | EndResize (const size_t theExtent, const size_t theNewBuckets, NCollection_ListNode **data1, NCollection_ListNode **data2) noexcept |
| | EndResize.
|
| |
| bool | Resizable () const noexcept |
| | Resizable.
|
| |
| size_t | Increment () noexcept |
| | Increment.
|
| |
| size_t | Decrement () noexcept |
| | Decrement.
|
| |
| void | Destroy (NCollection_DelMapNode fDel, bool doReleaseMemory=true) |
| | Destroy.
|
| |
| size_t | NextPrimeForMap (const size_t N) const noexcept |
| | NextPrimeForMap.
|
| |
| void | exchangeMapsData (NCollection_BaseMap &theOther) noexcept |
| | Exchange content of two maps without data copying.
|
| |
| NCollection_BaseMap & | operator= (NCollection_BaseMap &&) noexcept=delete |
| | Move operator.
|
| |
| | NCollection_BaseMap (const NCollection_BaseMap &)=delete |
| | Copy Constructor.
|
| |
| NCollection_BaseMap & | operator= (const NCollection_BaseMap &)=delete |
| | Assign operator.
|
| |
Hash map that preserves insertion order.
NCollection_OrderedDataMap is an alternative to NCollection_DataMap that maintains a doubly-linked list threaded through the hash nodes, so iteration always follows the order in which key-value pairs were inserted.
Key features:
- O(1) hash lookup (IsBound, Find, Seek, Contained)
- O(1) insertion at tail (Bind, Emplace)
- O(1) removal with linked-list unlink (UnBind)
- O(1) access to first/last inserted pairs (First, Last, FirstValue, LastValue)
- Deterministic iteration order across platforms
- Structured binding support via Items() view
Best suited for:
- Key-value maps that require stable iteration order
- Serialization-friendly maps (deterministic output)
- Property registries where definition order matters
- Cases where NCollection_IndexedDataMap overhead is unnecessary
Compared to NCollection_IndexedDataMap:
- UnBind is O(1) instead of O(n) (no swap-and-shrink on dense array)
- No integer index access (use IndexedDataMap if indices are needed)
The OrderedDataMap can be seen as an extended array where the Keys are the indices. For this reason the operator () is defined to fetch an Item from a Key.
The number of buckets is managed automatically and grows when the number of keys exceeds the bucket count.
- Note
- This class is NOT thread-safe. External synchronization is required for concurrent access from multiple threads.
- Template Parameters
-