# FoundationClasses
TKernel
NCollection

# FoundationClasses
TKernel
NCollection

# NCollection_Map< TheKeyType > Class Template Reference

`#include <NCollection_Map.hxx>`

Inheritance diagram for NCollection_Map< TheKeyType >:

[legend]

## Public Member Functions

| NCollection_Map (const Standard_Integer NbBuckets=1, const Handle(NCollection_BaseAllocator)&theAllocator=0L)
| Constructor.
| NCollection_Map (const NCollection_Map &theOther)
| Copy constructor.
virtual void | Assign (const NCollection_BaseCollection< TheKeyType > &theOther)
| Assign another collection.
NCollection_Map & | operator= (const NCollection_Map &theOther)
| = another map
void | ReSize (const Standard_Integer N)
| ReSize.
Standard_Boolean | Add (const TheKeyType &K)
| Add.
const TheKeyType & | Added (const TheKeyType &K)
| Added: add a new key if not yet in the map, and return reference to either newly added or previously existing object.
Standard_Boolean | Contains (const TheKeyType &K) const
| Contains.
Standard_Boolean | Remove (const TheKeyType &K)
| Remove.
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.
void | Clear (const Handle(NCollection_BaseAllocator)&theAllocator)
| Clear data and reset allocator.
| ~NCollection_Map (void)
| Destructor.
virtual Standard_Integer | Size (void) const
| Size.

## Private Member Functions

virtual TYPENAME NCollection_BaseCollection< TheKeyType >::Iterator & | CreateIterator (void) const
| Creates Iterator for use on BaseCollection.

## Data Structures

class | Iterator
| Implementation of the Iterator interface. More...
class | MapNode
| Adaptation of the TListNode to the map notations. More...

## Detailed Description

### template<class TheKeyType>
class NCollection_Map< TheKeyType >

Purpose: Single hashed Map. This Map is used to store and retrieve keys in linear time.

The ::Iterator class can be used to explore the content of the map. It is not wise to iterate and modify a map in parallel.

To compute the hashcode of the key the function HashCode must be defined in the global namespace

To compare two keys the function IsEqual must be defined in the global namespace.

The performance of a Map is conditionned by its number of buckets that should be kept greater to the number of keys. This map has an automatic management of the number of buckets. It is resized when the number of Keys becomes greater than the number of buckets.

If you have a fair idea of the number of objects you can save on automatic resizing by giving a number of buckets at creation or using the ReSize method. This should be consider only for crucial optimisation issues.

## Constructor & Destructor Documentation

template<class TheKeyType>
NCollection_Map< TheKeyType >::NCollection_Map | ( | const Standard_Integer | NbBuckets = `1`,
|  | const Handle(NCollection_BaseAllocator)& | theAllocator = `0L`
| ) | `[inline]`

template<class TheKeyType>
NCollection_Map< TheKeyType >::NCollection_Map | ( | const NCollection_Map< TheKeyType > & | theOther | ) | `[inline]`

template<class TheKeyType>
NCollection_Map< TheKeyType >::~NCollection_Map | ( | void |  | ) | `[inline]`

## Member Function Documentation

template<class TheKeyType>
Standard_Boolean NCollection_Map< TheKeyType >::Add | ( | const TheKeyType & | K | ) | `[inline]`

template<class TheKeyType>
const TheKeyType& NCollection_Map< TheKeyType >::Added | ( | const TheKeyType & | K | ) | `[inline]`

template<class TheKeyType>
virtual void NCollection_Map< TheKeyType >::Assign | ( | const NCollection_BaseCollection< TheKeyType > & | theOther | ) | `[inline, virtual]`

template<class TheKeyType>
void NCollection_Map< TheKeyType >::Clear | ( | const Handle(NCollection_BaseAllocator)& | theAllocator | ) | `[inline]`

template<class TheKeyType>
void NCollection_Map< TheKeyType >::Clear | ( | const Standard_Boolean | doReleaseMemory = `Standard_True` | ) | `[inline]`

template<class TheKeyType>
Standard_Boolean NCollection_Map< TheKeyType >::Contains | ( | const TheKeyType & | K | ) | const`[inline]`

template<class TheKeyType>
virtual TYPENAME NCollection_BaseCollection<TheKeyType>::Iterator& NCollection_Map< TheKeyType >::CreateIterator | ( | void |  | ) | const`[inline, private, virtual]`

| Implements NCollection_BaseCollection< TheKeyType >.

template<class TheKeyType>
NCollection_Map& NCollection_Map< TheKeyType >::operator= | ( | const NCollection_Map< TheKeyType > & | theOther | ) | `[inline]`

template<class TheKeyType>
Standard_Boolean NCollection_Map< TheKeyType >::Remove | ( | const TheKeyType & | K | ) | `[inline]`

template<class TheKeyType>
void NCollection_Map< TheKeyType >::ReSize | ( | const Standard_Integer | N | ) | `[inline]`

template<class TheKeyType>
virtual Standard_Integer NCollection_Map< TheKeyType >::Size | ( | void |  | ) | const`[inline, virtual]`

| Implements NCollection_BaseCollection< TheKeyType >.

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

- NCollection_Map.hxx