|
| 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.
|
| |
| | NCollection_OrderedMap () |
| | Empty constructor.
|
| |
| | NCollection_OrderedMap (const size_t theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor.
|
| |
| | NCollection_OrderedMap (const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor (legacy int-taking).
|
| |
| | NCollection_OrderedMap (const Hasher &theHasher, const size_t theNbBuckets=1, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (copy).
|
| |
| | NCollection_OrderedMap (const Hasher &theHasher, const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (copy, legacy int-taking).
|
| |
| | NCollection_OrderedMap (Hasher &&theHasher, const size_t theNbBuckets=1, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (move).
|
| |
| | NCollection_OrderedMap (Hasher &&theHasher, const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) |
| | Constructor with custom hasher (move, legacy int-taking).
|
| |
| | NCollection_OrderedMap (const NCollection_OrderedMap &theOther) |
| | Copy constructor.
|
| |
| | NCollection_OrderedMap (NCollection_OrderedMap &&theOther) noexcept |
| | Move constructor.
|
| |
| void | Exchange (NCollection_OrderedMap &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_OrderedMap & | Assign (const NCollection_OrderedMap &theOther) |
| | Assign. This method does not change the internal allocator.
|
| |
| NCollection_OrderedMap & | operator= (const NCollection_OrderedMap &theOther) |
| | Assign operator.
|
| |
| NCollection_OrderedMap & | operator= (NCollection_OrderedMap &&theOther) noexcept |
| | Move operator.
|
| |
| void | ReSize (const size_t N) |
| | ReSize.
|
| |
| void | ReSize (const int N) |
| |
| bool | Add (const TheKeyType &theKey) |
| | Add.
|
| |
| bool | Add (TheKeyType &&theKey) |
| | Add.
|
| |
| 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 object.
|
| |
| 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 object.
|
| |
| template<typename... Args> |
| bool | Emplace (Args &&... theArgs) |
| | Emplace constructs key in-place; if key exists, destroys and reconstructs.
|
| |
| template<typename... Args> |
| const TheKeyType & | Emplaced (Args &&... theArgs) |
| | Emplaced constructs key in-place; if key exists, destroys and reconstructs.
|
| |
| 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 | Contains (const TheKeyType &theKey) const |
| | Contains.
|
| |
| 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.
|
| |
| bool | Remove (const TheKeyType &K) |
| | Remove.
|
| |
| 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_OrderedMap () override |
| | Destructor.
|
| |
| const TheKeyType & | First () const |
| | Returns the first key in insertion order.
|
| |
| const TheKeyType & | Last () const |
| | Returns the last key 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, OrderedMapNode *&theNode, size_t &theHash) const |
| | Lookup for particular key in map.
|
| |
| bool | lookup (const TheKeyType &theKey, OrderedMapNode *&theNode) 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 (OrderedMapNode *theNode) |
| | Append a node to the tail of the insertion-order linked list.
|
| |
| void | unlinkFromList (OrderedMapNode *theNode) |
| | Unlink a node from the insertion-order linked list.
|
| |
| template<typename K , bool ReturnRef> |
| auto | addImpl (K &&theKey, std::bool_constant< ReturnRef >) -> std::conditional_t< ReturnRef, const TheKeyType &, bool > |
| | Implementation helper for Add/Added.
|
| |
| template<bool IsTry, bool ReturnRef, typename... Args> |
| auto | emplaceImpl (std::bool_constant< IsTry >, std::bool_constant< ReturnRef >, Args &&... theArgs) -> std::conditional_t< ReturnRef, const TheKeyType &, bool > |
| | Implementation helper for 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.
|
| |
template<
class TheKeyType,
class Hasher = NCollection_DefaultHasher<TheKeyType>>
class NCollection_OrderedMap< TheKeyType, Hasher >
Hash set that preserves insertion order.
NCollection_OrderedMap is an alternative to NCollection_Map that maintains a doubly-linked list threaded through the hash nodes, so iteration always follows the order in which keys were inserted.
Key features:
- O(1) hash lookup (Contains, Contained)
- O(1) insertion at tail (Add, Emplace)
- O(1) removal with linked-list unlink (Remove)
- O(1) access to first/last inserted keys (First, Last)
- Deterministic iteration order across platforms
Best suited for:
- Membership sets that require stable iteration order
- Serialization-friendly key sets (deterministic output)
- Cases where NCollection_IndexedMap overhead is unnecessary
Compared to NCollection_IndexedMap:
- Remove is O(1) instead of O(n) (no swap-and-shrink on dense array)
- No integer index access (use IndexedMap if indices are needed)
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
-