Open CASCADE Technology 7.8.0
Data Structures | Public Types | Public Member Functions | Protected Member Functions
NCollection_DataMap< TheKeyType, TheItemType, Hasher > Class Template Reference

#include <NCollection_DataMap.hxx>

Inheritance diagram for NCollection_DataMap< TheKeyType, TheItemType, Hasher >:
Inheritance graph
[legend]

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, falseiterator
 Shorthand for a regular iterator type.
 
typedef NCollection_StlIterator< std::forward_iterator_tag, Iterator, TheItemType, trueconst_iterator
 Shorthand for a constant iterator type.
 

Public Member Functions

iterator begin () const
 Returns an iterator pointing to the first element in the map.
 
iterator end () const
 Returns an iterator referring to the past-the-end element in the map.
 
const_iterator cbegin () const
 Returns a const iterator pointing to the first element in the map.
 
const_iterator cend () const
 Returns a const iterator referring to the past-the-end element in the map.
 
 NCollection_DataMap ()
 Empty Constructor.
 
 NCollection_DataMap (const Standard_Integer theNbBuckets, const Handle< NCollection_BaseAllocator > &theAllocator=0L)
 Constructor.
 
 NCollection_DataMap (const NCollection_DataMap &theOther)
 Copy constructor.
 
 NCollection_DataMap (NCollection_DataMap &&theOther) noexcept
 Move constructor.
 
void Exchange (NCollection_DataMap &theOther)
 Exchange the content of two maps without re-allocations. Notice that allocators will be swapped as well!
 
NCollection_DataMapAssign (const NCollection_DataMap &theOther)
 Assignment. This method does not change the internal allocator.
 
NCollection_DataMapoperator= (const NCollection_DataMap &theOther)
 Assignment operator.
 
NCollection_DataMapoperator= (NCollection_DataMap &&theOther) noexcept
 Move operator.
 
void ReSize (const Standard_Integer N)
 ReSize.
 
Standard_Boolean Bind (const TheKeyType &theKey, const TheItemType &theItem)
 Bind binds Item to Key in map.
 
Standard_Boolean Bind (TheKeyType &&theKey, const TheItemType &theItem)
 Bind binds Item to Key in map.
 
Standard_Boolean Bind (const TheKeyType &theKey, TheItemType &&theItem)
 Bind binds Item to Key in map.
 
Standard_Boolean Bind (TheKeyType &&theKey, TheItemType &&theItem)
 Bind binds Item to Key in map.
 
TheItemTypeBound (const TheKeyType &theKey, const TheItemType &theItem)
 Bound binds Item to Key in map.
 
TheItemTypeBound (TheKeyType &&theKey, const TheItemType &theItem)
 Bound binds Item to Key in map.
 
TheItemTypeBound (const TheKeyType &theKey, TheItemType &&theItem)
 Bound binds Item to Key in map.
 
TheItemTypeBound (TheKeyType &&theKey, TheItemType &&theItem)
 Bound binds Item to Key in map.
 
Standard_Boolean IsBound (const TheKeyType &theKey) const
 IsBound.
 
Standard_Boolean UnBind (const TheKeyType &theKey)
 UnBind removes Item Key pair from map.
 
const TheItemTypeSeek (const TheKeyType &theKey) const
 Seek returns pointer to Item by Key. Returns NULL is Key was not bound.
 
const TheItemTypeFind (const TheKeyType &theKey) const
 Find returns the Item for Key. Raises if Key was not bound.
 
Standard_Boolean Find (const TheKeyType &theKey, TheItemType &theValue) const
 Find Item for key with copying.
 
const TheItemTypeoperator() (const TheKeyType &theKey) const
 operator ()
 
TheItemTypeChangeSeek (const TheKeyType &theKey)
 ChangeSeek returns modifiable pointer to Item by Key. Returns NULL is Key was not bound.
 
TheItemTypeChangeFind (const TheKeyType &theKey)
 ChangeFind returns mofifiable Item by Key. Raises if Key was not bound.
 
TheItemTypeoperator() (const TheKeyType &theKey)
 operator ()
 
void Clear (const Standard_Boolean doReleaseMemory=Standard_False)
 Clear data. If doReleaseMemory is false then the table of buckets is not released and will be reused.
 
void Clear (const Handle< NCollection_BaseAllocator > &theAllocator)
 Clear data and reset allocator.
 
virtual ~NCollection_DataMap (void)
 Destructor.
 
Standard_Integer Size (void) const
 Size.
 
- Public Member Functions inherited from NCollection_BaseMap
Standard_Integer NbBuckets () const
 NbBuckets.
 
Standard_Integer Extent () const
 Extent.
 
Standard_Boolean IsEmpty () const
 IsEmpty.
 
void Statistics (Standard_OStream &S) const
 Statistics.
 
const Handle< NCollection_BaseAllocator > & Allocator () const
 Returns attached allocator.
 

Protected Member Functions

Standard_Boolean lookup (const TheKeyType &theKey, DataMapNode *&theNode) const
 Lookup for particular key in map.
 
Standard_Boolean 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 int theUpperBound) const
 
- Protected Member Functions inherited from NCollection_BaseMap
 NCollection_BaseMap (const Standard_Integer NbBuckets, const Standard_Boolean single, const Handle< NCollection_BaseAllocator > &theAllocator)
 Constructor.
 
 NCollection_BaseMap (NCollection_BaseMap &&theOther) noexcept
 Move Constructor.
 
virtual ~NCollection_BaseMap ()
 Destructor.
 
Standard_Boolean BeginResize (const Standard_Integer NbBuckets, Standard_Integer &NewBuckets, NCollection_ListNode **&data1, NCollection_ListNode **&data2) const
 BeginResize.
 
void EndResize (const Standard_Integer NbBuckets, const Standard_Integer NewBuckets, NCollection_ListNode **data1, NCollection_ListNode **data2)
 EndResize.
 
Standard_Boolean Resizable () const
 Resizable.
 
Standard_Integer Increment ()
 Increment.
 
Standard_Integer Decrement ()
 Decrement.
 
void Destroy (NCollection_DelMapNode fDel, Standard_Boolean doReleaseMemory=Standard_True)
 Destroy.
 
Standard_Integer NextPrimeForMap (const Standard_Integer N) const
 NextPrimeForMap.
 
void exchangeMapsData (NCollection_BaseMap &theOther)
 Exchange content of two maps without data copying.
 
NCollection_BaseMapoperator= (NCollection_BaseMap &&) noexcept=delete
 Move operator.
 
 NCollection_BaseMap (const NCollection_BaseMap &)=delete
 Copy Constructor.
 
NCollection_BaseMapoperator= (const NCollection_BaseMap &)=delete
 Assign operator.
 

Additional Inherited Members

- Protected Attributes inherited from NCollection_BaseMap
Handle< NCollection_BaseAllocatormyAllocator
 
NCollection_ListNode ** myData1
 
NCollection_ListNode ** myData2
 

Detailed Description

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
class NCollection_DataMap< TheKeyType, TheItemType, Hasher >

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.

Member Typedef Documentation

◆ const_iterator

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
typedef NCollection_StlIterator<std::forward_iterator_tag, Iterator, TheItemType, true> NCollection_DataMap< TheKeyType, TheItemType, Hasher >::const_iterator

Shorthand for a constant iterator type.

◆ iterator

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
typedef NCollection_StlIterator<std::forward_iterator_tag, Iterator, TheItemType, false> NCollection_DataMap< TheKeyType, TheItemType, Hasher >::iterator

Shorthand for a regular iterator type.

◆ key_type

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
typedef TheKeyType NCollection_DataMap< TheKeyType, TheItemType, Hasher >::key_type

STL-compliant typedef for key type.

◆ value_type

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
typedef TheItemType NCollection_DataMap< TheKeyType, TheItemType, Hasher >::value_type

STL-compliant typedef for value type.

Constructor & Destructor Documentation

◆ NCollection_DataMap() [1/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap< TheKeyType, TheItemType, Hasher >::NCollection_DataMap ( )
inline

Empty Constructor.

◆ NCollection_DataMap() [2/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap< TheKeyType, TheItemType, Hasher >::NCollection_DataMap ( const Standard_Integer  theNbBuckets,
const Handle< NCollection_BaseAllocator > &  theAllocator = 0L 
)
inlineexplicit

Constructor.

◆ NCollection_DataMap() [3/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap< TheKeyType, TheItemType, Hasher >::NCollection_DataMap ( const NCollection_DataMap< TheKeyType, TheItemType, Hasher > &  theOther)
inline

Copy constructor.

◆ NCollection_DataMap() [4/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap< TheKeyType, TheItemType, Hasher >::NCollection_DataMap ( NCollection_DataMap< TheKeyType, TheItemType, Hasher > &&  theOther)
inlinenoexcept

Move constructor.

◆ ~NCollection_DataMap()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
virtual NCollection_DataMap< TheKeyType, TheItemType, Hasher >::~NCollection_DataMap ( void  )
inlinevirtual

Destructor.

Member Function Documentation

◆ Assign()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Assign ( const NCollection_DataMap< TheKeyType, TheItemType, Hasher > &  theOther)
inline

Assignment. This method does not change the internal allocator.

◆ begin()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
iterator NCollection_DataMap< TheKeyType, TheItemType, Hasher >::begin ( ) const
inline

Returns an iterator pointing to the first element in the map.

◆ Bind() [1/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bind ( const TheKeyType theKey,
const TheItemType theItem 
)
inline

Bind binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
Standard_True if Key was not bound already

◆ Bind() [2/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bind ( const TheKeyType theKey,
TheItemType &&  theItem 
)
inline

Bind binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
Standard_True if Key was not bound already

◆ Bind() [3/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bind ( TheKeyType &&  theKey,
const TheItemType theItem 
)
inline

Bind binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
Standard_True if Key was not bound already

◆ Bind() [4/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bind ( TheKeyType &&  theKey,
TheItemType &&  theItem 
)
inline

Bind binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
Standard_True if Key was not bound already

◆ Bound() [1/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType * NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bound ( const TheKeyType theKey,
const TheItemType theItem 
)
inline

Bound binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
pointer to modifiable Item

◆ Bound() [2/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType * NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bound ( const TheKeyType theKey,
TheItemType &&  theItem 
)
inline

Bound binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
pointer to modifiable Item

◆ Bound() [3/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType * NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bound ( TheKeyType &&  theKey,
const TheItemType theItem 
)
inline

Bound binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
pointer to modifiable Item

◆ Bound() [4/4]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType * NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Bound ( TheKeyType &&  theKey,
TheItemType &&  theItem 
)
inline

Bound binds Item to Key in map.

Parameters
theKeykey to add/update
theItemnew item; overrides value previously bound to the key
Returns
pointer to modifiable Item

◆ cbegin()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
const_iterator NCollection_DataMap< TheKeyType, TheItemType, Hasher >::cbegin ( ) const
inline

Returns a const iterator pointing to the first element in the map.

◆ cend()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
const_iterator NCollection_DataMap< TheKeyType, TheItemType, Hasher >::cend ( ) const
inline

Returns a const iterator referring to the past-the-end element in the map.

◆ ChangeFind()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::ChangeFind ( const TheKeyType theKey)
inline

ChangeFind returns mofifiable Item by Key. Raises if Key was not bound.

◆ ChangeSeek()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType * NCollection_DataMap< TheKeyType, TheItemType, Hasher >::ChangeSeek ( const TheKeyType theKey)
inline

ChangeSeek returns modifiable pointer to Item by Key. Returns NULL is Key was not bound.

◆ Clear() [1/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Clear ( const Handle< NCollection_BaseAllocator > &  theAllocator)
inline

Clear data and reset allocator.

◆ Clear() [2/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Clear ( const Standard_Boolean  doReleaseMemory = Standard_False)
inline

Clear data. If doReleaseMemory is false then the table of buckets is not released and will be reused.

◆ end()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
iterator NCollection_DataMap< TheKeyType, TheItemType, Hasher >::end ( ) const
inline

Returns an iterator referring to the past-the-end element in the map.

◆ Exchange()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Exchange ( NCollection_DataMap< TheKeyType, TheItemType, Hasher > &  theOther)
inline

Exchange the content of two maps without re-allocations. Notice that allocators will be swapped as well!

◆ Find() [1/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Find ( const TheKeyType theKey) const
inline

Find returns the Item for Key. Raises if Key was not bound.

◆ Find() [2/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Find ( const TheKeyType theKey,
TheItemType theValue 
) const
inline

Find Item for key with copying.

Returns
true if key was found

◆ HashCode()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
size_t NCollection_DataMap< TheKeyType, TheItemType, Hasher >::HashCode ( const TheKeyType theKey,
const int  theUpperBound 
) const
inlineprotected

◆ IsBound()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::IsBound ( const TheKeyType theKey) const
inline

IsBound.

◆ IsEqual()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
bool NCollection_DataMap< TheKeyType, TheItemType, Hasher >::IsEqual ( const TheKeyType theKey1,
const TheKeyType theKey2 
) const
inlineprotected

◆ lookup() [1/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::lookup ( const TheKeyType theKey,
DataMapNode *&  theNode 
) const
inlineprotected

Lookup for particular key in map.

Parameters
[in]theKeykey to compute hash
[out]theNodethe detected node with equal key. Can be null.
Returns
true if key is found

◆ lookup() [2/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::lookup ( const TheKeyType theKey,
DataMapNode *&  theNode,
size_t theHash 
) const
inlineprotected

Lookup for particular key in map.

Parameters
[in]theKeykey to compute hash
[out]theNodethe detected node with equal key. Can be null.
[out]theHashcomputed bounded hash code for current key.
Returns
true if key is found

◆ operator()() [1/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::operator() ( const TheKeyType theKey)
inline

operator ()

◆ operator()() [2/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::operator() ( const TheKeyType theKey) const
inline

operator ()

◆ operator=() [1/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::operator= ( const NCollection_DataMap< TheKeyType, TheItemType, Hasher > &  theOther)
inline

Assignment operator.

◆ operator=() [2/2]

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_DataMap & NCollection_DataMap< TheKeyType, TheItemType, Hasher >::operator= ( NCollection_DataMap< TheKeyType, TheItemType, Hasher > &&  theOther)
inlinenoexcept

Move operator.

◆ ReSize()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_DataMap< TheKeyType, TheItemType, Hasher >::ReSize ( const Standard_Integer  N)
inline

ReSize.

◆ Seek()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType * NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Seek ( const TheKeyType theKey) const
inline

Seek returns pointer to Item by Key. Returns NULL is Key was not bound.

◆ Size()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Integer NCollection_DataMap< TheKeyType, TheItemType, Hasher >::Size ( void  ) const
inline

Size.

◆ UnBind()

template<class TheKeyType , class TheItemType , class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_DataMap< TheKeyType, TheItemType, Hasher >::UnBind ( const TheKeyType theKey)
inline

UnBind removes Item Key pair from map.


The documentation for this class was generated from the following file: