Open CASCADE Technology  7.1.0.beta
Data Structures | Public Types | Public Member Functions

NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher > Class Template Reference

#include <NCollection_IndexedDataMap.hxx>

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

Data Structures

class  Iterator
 Implementation of the Iterator interface. More...
 

Public Types

typedef NCollection_StlIterator< std::forward_iterator_tag, Iterator, TheItemType, false > iterator
 Shorthand for a regular iterator type. More...
 
typedef NCollection_StlIterator< std::forward_iterator_tag, Iterator, TheItemType, true > const_iterator
 Shorthand for a constant iterator type. More...
 

Public Member Functions

iterator begin () const
 Returns an iterator pointing to the first element in the map. More...
 
iterator end () const
 Returns an iterator referring to the past-the-end element in the map. More...
 
const_iterator cbegin () const
 Returns a const iterator pointing to the first element in the map. More...
 
const_iterator cend () const
 Returns a const iterator referring to the past-the-end element in the map. More...
 
 NCollection_IndexedDataMap (const Standard_Integer NbBuckets=1, const Handle< NCollection_BaseAllocator > &theAllocator=0L)
 Constructor. More...
 
 NCollection_IndexedDataMap (const NCollection_IndexedDataMap &theOther)
 Copy constructor. More...
 
void Exchange (NCollection_IndexedDataMap &theOther)
 Exchange the content of two maps without re-allocations. Notice that allocators will be swapped as well! More...
 
NCollection_IndexedDataMapAssign (const NCollection_IndexedDataMap &theOther)
 Assignment. This method does not change the internal allocator. More...
 
NCollection_IndexedDataMapoperator= (const NCollection_IndexedDataMap &theOther)
 Assignment operator. More...
 
void ReSize (const Standard_Integer N)
 ReSize. More...
 
Standard_Integer Add (const TheKeyType &theKey1, const TheItemType &theItem)
 Add. More...
 
Standard_Boolean Contains (const TheKeyType &theKey1) const
 Contains. More...
 
void Substitute (const Standard_Integer theIndex, const TheKeyType &theKey1, const TheItemType &theItem)
 Substitute. More...
 
void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2)
 Swaps two elements with the given indices. More...
 
void RemoveLast (void)
 RemoveLast. More...
 
const TheKeyType & FindKey (const Standard_Integer theKey2) const
 FindKey. More...
 
const TheItemType & FindFromIndex (const Standard_Integer theKey2) const
 FindFromIndex. More...
 
const TheItemType & operator() (const Standard_Integer theKey2) const
 operator () More...
 
TheItemType & ChangeFromIndex (const Standard_Integer theKey2)
 ChangeFromIndex. More...
 
TheItemType & operator() (const Standard_Integer theKey2)
 operator () More...
 
Standard_Integer FindIndex (const TheKeyType &theKey1) const
 FindIndex. More...
 
const TheItemType & FindFromKey (const TheKeyType &theKey1) const
 FindFromKey. More...
 
TheItemType & ChangeFromKey (const TheKeyType &theKey1)
 ChangeFromKey. More...
 
const TheItemType * Seek (const TheKeyType &theKey1) const
 Seek returns pointer to Item by Key. Returns NULL if Key was not found. More...
 
TheItemType * ChangeSeek (const TheKeyType &theKey1)
 ChangeSeek returns modifiable pointer to Item by Key. Returns NULL if Key was not found. More...
 
Standard_Boolean FindFromKey (const TheKeyType &theKey1, TheItemType &theValue) const
 Find value for key with copying. More...
 
void Clear (const Standard_Boolean doReleaseMemory=Standard_True)
 Clear data. If doReleaseMemory is false then the table of buckets is not released and will be reused. More...
 
void Clear (const Handle< NCollection_BaseAllocator > &theAllocator)
 Clear data and reset allocator. More...
 
virtual ~NCollection_IndexedDataMap (void)
 Destructor. More...
 
Standard_Integer Size (void) const
 Size. More...
 
- Public Member Functions inherited from NCollection_BaseMap
Standard_Integer NbBuckets () const
 NbBuckets. More...
 
Standard_Integer Extent () const
 Extent. More...
 
Standard_Boolean IsEmpty () const
 IsEmpty. More...
 
void Statistics (Standard_OStream &S) const
 Statistics. More...
 
const Handle< NCollection_BaseAllocator > & Allocator () const
 Returns attached allocator. More...
 

Additional Inherited Members

- Protected Member Functions inherited from NCollection_BaseMap
 NCollection_BaseMap (const Standard_Integer NbBuckets, const Standard_Boolean single, const Handle< NCollection_BaseAllocator > &theAllocator)
 Constructor. More...
 
virtual ~NCollection_BaseMap ()
 Destructor. More...
 
Standard_Boolean BeginResize (const Standard_Integer NbBuckets, Standard_Integer &NewBuckets, NCollection_ListNode **&data1, NCollection_ListNode **&data2) const
 BeginResize. More...
 
void EndResize (const Standard_Integer NbBuckets, const Standard_Integer NewBuckets, NCollection_ListNode **data1, NCollection_ListNode **data2)
 EndResize. More...
 
Standard_Boolean Resizable () const
 Resizable. More...
 
void Increment ()
 Increment. More...
 
void Decrement ()
 Decrement. More...
 
void Destroy (NCollection_DelMapNode fDel, Standard_Boolean doReleaseMemory=Standard_True)
 Destroy. More...
 
Standard_Integer NextPrimeForMap (const Standard_Integer N) const
 NextPrimeForMap. More...
 
void exchangeMapsData (NCollection_BaseMap &theOther)
 Exchange content of two maps without data copying. More...
 
- 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_IndexedDataMap< TheKeyType, TheItemType, Hasher >

Purpose: An indexed map is used to store keys and to bind an index to them. Each new key stored in the map gets an index. Index are incremented as keys are stored in the map. A key can be found by the index and an index by the key. No key but the last can be removed so the indices are in the range 1.. Extent. An Item is stored with each key.

This class is similar to IndexedMap from NCollection with the Item as a new feature. Note the important difference on the operator (). In the IndexedMap this operator returns the Key. In the IndexedDataMap this operator returns the Item.

See the class Map from NCollection for a discussion about the number of buckets.

Member Typedef Documentation

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

Shorthand for a constant iterator type.

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

Shorthand for a regular iterator type.

Constructor & Destructor Documentation

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::NCollection_IndexedDataMap ( const Standard_Integer  NbBuckets = 1,
const Handle< NCollection_BaseAllocator > &  theAllocator = 0L 
)
inline

Constructor.

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

Copy constructor.

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

Destructor.

Member Function Documentation

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Integer NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::Add ( const TheKeyType &  theKey1,
const TheItemType &  theItem 
)
inline

Add.

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

Assignment. This method does not change the internal allocator.

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

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

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

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

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

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

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::ChangeFromIndex ( const Standard_Integer  theKey2)
inline

ChangeFromIndex.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::ChangeFromKey ( const TheKeyType &  theKey1)
inline

ChangeFromKey.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType* NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::ChangeSeek ( const TheKeyType &  theKey1)
inline

ChangeSeek returns modifiable pointer to Item by Key. Returns NULL if Key was not found.

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

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

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

Clear data and reset allocator.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::Contains ( const TheKeyType &  theKey1) const
inline

Contains.

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

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

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

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

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::FindFromIndex ( const Standard_Integer  theKey2) const
inline

FindFromIndex.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::FindFromKey ( const TheKeyType &  theKey1) const
inline

FindFromKey.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Boolean NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::FindFromKey ( const TheKeyType &  theKey1,
TheItemType &  theValue 
) const
inline

Find value for key with copying.

Returns
true if key was found
template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
Standard_Integer NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::FindIndex ( const TheKeyType &  theKey1) const
inline

FindIndex.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheKeyType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::FindKey ( const Standard_Integer  theKey2) const
inline

FindKey.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::operator() ( const Standard_Integer  theKey2) const
inline

operator ()

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
TheItemType& NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::operator() ( const Standard_Integer  theKey2)
inline

operator ()

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

Assignment operator.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::RemoveLast ( void  )
inline

RemoveLast.

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

ReSize.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
const TheItemType* NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::Seek ( const TheKeyType &  theKey1) const
inline

Seek returns pointer to Item by Key. Returns NULL if Key was not found.

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

Size.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::Substitute ( const Standard_Integer  theIndex,
const TheKeyType &  theKey1,
const TheItemType &  theItem 
)
inline

Substitute.

template<class TheKeyType, class TheItemType, class Hasher = NCollection_DefaultHasher<TheKeyType>>
void NCollection_IndexedDataMap< TheKeyType, TheItemType, Hasher >::Swap ( const Standard_Integer  theIndex1,
const Standard_Integer  theIndex2 
)
inline

Swaps two elements with the given indices.


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