![]() |
Open CASCADE Technology Reference Manual 8.0.0
|
#include <NCollection_DataMap.hxx>

Data Structures | |
| class | DataMapNode |
| class | Iterator |
Public Types | |
| typedef TheKeyType | key_type |
| STL-compliant typedef for key type. | |
| typedef TheItemType | value_type |
| STL-compliant typedef for value type. | |
| typedef NCollection_StlIterator< std::forward_iterator_tag, Iterator, TheItemType, false > | iterator |
| Shorthand for a regular iterator type. | |
| typedef NCollection_StlIterator< std::forward_iterator_tag, Iterator, TheItemType, true > | const_iterator |
| Shorthand for a constant iterator type. | |
| using | KeyValueRef = NCollection_ItemsView::KeyValueRef<TheKeyType, TheItemType, false> |
| Key-value pair reference for structured binding support. Enables: for (auto [key, value] : map.Items()) | |
| using | ConstKeyValueRef = NCollection_ItemsView::KeyValueRef<TheKeyType, TheItemType, true> |
| Const key-value pair reference for structured binding support. | |
| using | ItemsView |
| View class for key-value pair iteration (mutable). | |
| using | ConstItemsView |
| View class for key-value pair iteration (const). | |
Public Member Functions | |
| 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_DataMap () | |
| Empty Constructor. | |
| NCollection_DataMap (const size_t theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) | |
| Constructor. | |
| NCollection_DataMap (const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) | |
| Constructor (legacy int-taking). | |
| NCollection_DataMap (const Hasher &theHasher, const size_t theNbBuckets=1, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) | |
| Constructor with custom hasher (copy). | |
| NCollection_DataMap (const Hasher &theHasher, const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) | |
| Constructor with custom hasher (copy, legacy int-taking). | |
| NCollection_DataMap (Hasher &&theHasher, const size_t theNbBuckets=1, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) | |
| Constructor with custom hasher (move). | |
| NCollection_DataMap (Hasher &&theHasher, const int theNbBuckets, const occ::handle< NCollection_BaseAllocator > &theAllocator=nullptr) | |
| Constructor with custom hasher (move, legacy int-taking). | |
| NCollection_DataMap (const NCollection_DataMap &theOther) | |
| Copy constructor. | |
| NCollection_DataMap (NCollection_DataMap &&theOther) noexcept | |
| Move constructor. | |
| void | Exchange (NCollection_DataMap &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_DataMap & | Assign (const NCollection_DataMap &theOther) |
| Assignment. This method does not change the internal allocator. | |
| NCollection_DataMap & | operator= (const NCollection_DataMap &theOther) |
| Assignment operator. | |
| NCollection_DataMap & | operator= (NCollection_DataMap &&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 is 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 is 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_DataMap () override | |
| Destructor. | |
Public Member Functions inherited from NCollection_BaseMap | |
| 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. | |
Protected Member Functions | |
| bool | lookup (const TheKeyType &theKey, DataMapNode *&theNode) const |
| Lookup for particular key in map. | |
| bool | lookup (const TheKeyType &theKey, DataMapNode *&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 |
| 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. Uses destroy + reconstruct in-place instead of assignment operator. | |
Protected Member Functions inherited from NCollection_BaseMap | |
| 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. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from NCollection_BaseMap | |
| static size_t | NbBucketsFromInt (const int theNbBuckets) |
| Converts legacy int bucket count to size_t with validation. | |
Protected Attributes inherited from NCollection_BaseMap | |
| occ::handle< NCollection_BaseAllocator > | myAllocator |
| NCollection_ListNode ** | myData1 |
| NCollection_ListNode ** | myData2 |
Purpose: The DataMap is a Map to store keys with associated Items. See Map from NCollection for a discussion about the number of buckets.
The DataMap can be seen as an extended array where the Keys are the indices. For this reason the operator () is defined on DataMap to fetch an Item from a Key. So the following syntax can be used :
anItem = aMap(aKey); aMap(aKey) = anItem;
This analogy has its limit. aMap(aKey) = anItem can be done only if aKey was previously bound to an item in the map.
| typedef NCollection_StlIterator<std::forward_iterator_tag, Iterator, TheItemType, true> NCollection_DataMap< TheKeyType, TheItemType, Hasher >::const_iterator |
Shorthand for a constant iterator type.
| using NCollection_DataMap< TheKeyType, TheItemType, Hasher >::ConstItemsView |
View class for key-value pair iteration (const).
| using NCollection_DataMap< TheKeyType, TheItemType, Hasher >::ConstKeyValueRef = NCollection_ItemsView::KeyValueRef<TheKeyType, TheItemType, true> |
Const key-value pair reference for structured binding support.
| using NCollection_DataMap< TheKeyType, TheItemType, Hasher >::ItemsView |
View class for key-value pair iteration (mutable).
| typedef NCollection_StlIterator<std::forward_iterator_tag, Iterator, TheItemType, false> NCollection_DataMap< TheKeyType, TheItemType, Hasher >::iterator |
Shorthand for a regular iterator type.
| typedef TheKeyType NCollection_DataMap< TheKeyType, TheItemType, Hasher >::key_type |
STL-compliant typedef for key type.
| using NCollection_DataMap< TheKeyType, TheItemType, Hasher >::KeyValueRef = NCollection_ItemsView::KeyValueRef<TheKeyType, TheItemType, false> |
Key-value pair reference for structured binding support. Enables: for (auto [key, value] : map.Items())
| typedef TheItemType NCollection_DataMap< TheKeyType, TheItemType, Hasher >::value_type |
STL-compliant typedef for value type.
|
inline |
Empty Constructor.
|
inlineexplicit |
Constructor.
|
inlineexplicit |
Constructor (legacy int-taking).
|
inlineexplicit |
Constructor with custom hasher (copy).
| theHasher | custom hasher instance |
| theNbBuckets | initial number of buckets |
| theAllocator | custom memory allocator |
|
inlineexplicit |
Constructor with custom hasher (copy, legacy int-taking).
|
inlineexplicit |
Constructor with custom hasher (move).
| theHasher | custom hasher instance (moved) |
| theNbBuckets | initial number of buckets |
| theAllocator | custom memory allocator |
|
inlineexplicit |
Constructor with custom hasher (move, legacy int-taking).
|
inline |
Copy constructor.
|
inlinenoexcept |
Move constructor.
|
inlineoverride |
Destructor.
|
inline |
Assignment. This method does not change the internal allocator.
|
inlinenoexcept |
Returns an iterator pointing to the first element in the map.
|
inline |
Bind binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bind binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bind binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bind binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bound binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bound binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bound binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inline |
Bound binds Item to Key in map.
| theKey | key to add/update |
| theItem | new item; overrides value previously bound to the key (uses destroy+reconstruct) |
|
inlinenoexcept |
Returns a const iterator pointing to the first element in the map.
|
inlinenoexcept |
Returns a const iterator referring to the past-the-end element in the map.
|
inline |
ChangeFind returns modifiable Item by Key. Raises if Key was not bound.
|
inline |
ChangeSeek returns modifiable pointer to Item by Key. Returns NULL is Key was not bound.
|
inline |
Clear data. If doReleaseMemory is false then the table of buckets is not released and will be reused.
|
inline |
Clear data and reset allocator.
|
inline |
Contained returns optional pair of const key reference and mutable value reference. Returns std::nullopt if the key is not found.
|
inline |
Contained returns optional pair of const references to key and value. Returns std::nullopt if the key is not found.
|
inline |
Emplace constructs value in-place; if key exists, destroys and reconstructs value.
| theKey | key to add/update |
| theArgs | arguments forwarded to value constructor |
|
inline |
Emplaced constructs value in-place; if key exists, destroys and reconstructs value.
| theKey | key to add/update |
| theArgs | arguments forwarded to value constructor |
|
inlineprotected |
Implementation helper for Bind/TryBind/Bound/TryBound/Emplace/TryEmplace/Emplaced/TryEmplaced. Uses destroy + reconstruct in-place instead of assignment operator.
| K | forwarding reference type for key |
| IsTry | if true, does not overwrite existing; if false, destroys and reconstructs |
| ReturnRef | if true, returns reference; if false, returns bool |
| theKey | key to add/update |
| theArgs | arguments forwarded to value constructor |
|
inlinenoexcept |
Returns an iterator referring to the past-the-end element in the map.
|
inlinenoexcept |
Exchange the content of two maps without re-allocations. Notice that allocators will be swapped as well!
|
inline |
Find returns the Item for Key. Raises if Key was not bound.
|
inline |
Find Item for key with copying.
|
inlinenoexcept |
Returns const reference to the hasher.
|
inlineprotected |
|
inline |
IsBound.
|
inlineprotected |
|
inline |
Returns a view for key-value pair iteration. Usage: for (auto [aKey, aValue] : aMap.Items())
|
inline |
Returns a const view for key-value pair iteration. Usage: for (const auto& [aKey, aValue] : aMap.Items())
|
inlineprotected |
Lookup for particular key in map.
| [in] | theKey | key to compute hash |
| [out] | theNode | the detected node with equal key. Can be null. |
|
inlineprotected |
Lookup for particular key in map.
| [in] | theKey | key to compute hash |
| [out] | theNode | the detected node with equal key. Can be null. |
| [out] | theHash | computed bounded hash code for current key. |
|
inline |
operator ()
|
inline |
operator ()
|
inline |
Assignment operator.
|
inlinenoexcept |
Move operator.
|
inline |
|
inline |
ReSize.
|
inline |
Seek returns pointer to Item by Key. Returns NULL is Key was not bound.
|
inline |
TryBind binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBind binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBind binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBind binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBound binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBound binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBound binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryBound binds Item to Key in map only if Key is not yet bound.
| theKey | key to add |
| theItem | item to bind if Key is not yet bound |
|
inline |
TryEmplace constructs value in-place only if key not already bound.
| theKey | key to add |
| theArgs | arguments forwarded to value constructor |
|
inline |
TryEmplaced constructs value in-place only if key not already bound.
| theKey | key to add |
| theArgs | arguments forwarded to value constructor |
|
inline |
UnBind removes Item Key pair from map.