# FoundationClasses
TKernel
TCollection

# TCollection_BasicMap Class Reference

Root class of all the maps, provides utilitites
for managing the buckets.
Maps are dynamically extended data structures where
data is quickly accessed with a key.
General properties of maps
- Map items may be (complex) non-unitary data; they
may be difficult to manage with an array. Moreover, the
map allows a data structure to be indexed by complex data.
- The size of a map is dynamically extended. So a map
may be first dimensioned for a little number of items.
Maps avoid the use of large and quasi-empty arrays.
- The access to a map item is much faster than the one
to a sequence, a list, a queue or a stack item.
- The access time to a map item may be compared with
the one to an array item. First of all, it depends on the
size of the map. It also depends on the quality of a user
redefinable function (the hashing function) to find
quickly where the item is.
- The exploration of a map may be of better performance
than the exploration of an array because the size of the
map is adapted to the number of inserted items.
These properties explain why maps are commonly used as
internal data structures for algorithms.
Definitions
- A map is a data structure for which data is addressed by keys.
- Once inserted in the map, a map item is referenced as an entry of the map.
- Each entry of the map is addressed by a key. Two
different keys address two different entries of the map.
- The position of an entry in the map is called a bucket.
- A map is dimensioned by its number of buckets, i.e. the
maximum number of entries in the map. The
performance of a map is conditioned by the number of buckets.
- The hashing function transforms a key into a bucket
index. The number of values that can be computed by
the hashing function is equal to the number of buckets of the map.
- Both the hashing function and the equality test
between two keys are provided by a hasher object.
- A map may be explored by a map iterator. This
exploration provides only inserted entries in the map
(i.e. non empty buckets).
Collections' generic maps
The Collections component provides numerous generic derived maps.
- These maps include automatic management of the
number of buckets: they are automatically resized when
the number of keys exceeds the number of buckets. If
you have a fair idea of the number of items in your map,
you can save on automatic resizing by specifying a
number of buckets at the time of construction, or by using
a resizing function. This may be considered for crucial optimization issues.
- Keys, items and hashers are parameters of these generic derived maps.
- TCollection_MapHasher class describes the
functions required by any hasher which is to be used
with a map instantiated from the Collections component.
- An iterator class is automatically instantiated at the
time of instantiation of a map provided by the
Collections component if this map is to be explored
with an iterator. Note that some provided generic maps
are not to be explored with an iterator but with indexes (indexed maps).
.

`#include <TCollection_BasicMap.hxx>`

Inheritance diagram for TCollection_BasicMap:

[legend]

## Public Member Functions

void * | operator new (size_t, void *anAddress)
void * | operator new (size_t size)
void | operator delete (void *anAddress)
Standard_Integer | NbBuckets () const
| Returns the number of buckets in <me>. .
Standard_Integer | Extent () const
| Returns the number of keys already stored in <me>. .
Standard_Boolean | IsEmpty () const
| Returns True when the map contains no keys. This is exactly Extent() == 0. .
Standard_EXPORT void | Statistics (Standard_OStream &S) const
| Prints on <s> usefull statistics about the map <me>. It can be used to test the quality of the hashcoding. .

## Protected Member Functions

Standard_EXPORT | TCollection_BasicMap (const Standard_Integer NbBuckets, const Standard_Boolean single)
| Initialize the map. Single is True when the map uses only one table of buckets. One table : Map, DataMap Two tables : DoubleMap, IndexedMap, IndexedDataMap .
Standard_EXPORT Standard_Boolean | BeginResize (const Standard_Integer NbBuckets, Standard_Integer &NewBuckets, Standard_Address &data1, Standard_Address &data2) const
| Tries to resize the Map with NbBuckets. Returns True if possible, NewBuckts is the new nuber of buckets. data1 and data2 are the new tables of buckets where the data must be copied. .
Standard_EXPORT void | EndResize (const Standard_Integer NbBuckets, const Standard_Integer NewBuckets, const Standard_Address data1, const Standard_Address data2)
| If BeginResize was succesfull after copying the data to data1 and data2 this methods update the tables and destroys the old ones. .
Standard_Boolean | Resizable () const
| Returns True if resizing the map should be considered. .
void | Increment ()
| Decrement the extent of the map. .
void | Decrement ()
| Decrement the extent of the map. .
Standard_EXPORT void | Destroy ()
| Destroys the buckets. .

## Protected Attributes

Standard_Address | myData1
Standard_Address | myData2

## Private Attributes

Standard_Boolean | isDouble
Standard_Boolean | mySaturated
Standard_Integer | myNbBuckets
Standard_Integer | mySize

## Constructor & Destructor Documentation

Standard_EXPORT TCollection_BasicMap::TCollection_BasicMap | ( | const Standard_Integer | NbBuckets,
|  | const Standard_Boolean | single
| ) | `[protected]`

## Member Function Documentation

Standard_EXPORT Standard_Boolean TCollection_BasicMap::BeginResize | ( | const Standard_Integer | NbBuckets,
|  | Standard_Integer & | NewBuckets,
|  | Standard_Address & | data1,
|  | Standard_Address & | data2
| ) | const`[protected]`

void TCollection_BasicMap::Decrement | ( |  | ) | `[inline, protected]`

Standard_EXPORT void TCollection_BasicMap::Destroy | ( |  | ) | `[protected]`

Standard_EXPORT void TCollection_BasicMap::EndResize | ( | const Standard_Integer | NbBuckets,
|  | const Standard_Integer | NewBuckets,
|  | const Standard_Address | data1,
|  | const Standard_Address | data2
| ) | `[protected]`

Standard_Integer TCollection_BasicMap::Extent | ( |  | ) | const`[inline]`

| Reimplemented in TColStd_PackedMapOfInteger.

void TCollection_BasicMap::Increment | ( |  | ) | `[inline, protected]`

Standard_Boolean TCollection_BasicMap::IsEmpty | ( |  | ) | const`[inline]`

| Reimplemented in TColStd_PackedMapOfInteger.

Standard_Integer TCollection_BasicMap::NbBuckets | ( |  | ) | const`[inline]`

| Reimplemented in TColStd_PackedMapOfInteger.

void TCollection_BasicMap::operator delete | ( | void * | anAddress | ) | `[inline]`

Reimplemented in Expr_MapOfNamedUnknown, GraphDS_EntityRoleMap, Plugin_MapOfFunctions, Resource_DataMapOfAsciiStringAsciiString, Resource_DataMapOfAsciiStringExtendedString, Storage_MapOfAsciiString, Storage_MapOfCallBack, Storage_MapOfPers, Storage_PType, TColgp_DataMapOfIntegerCirc2d, TColStd_DataMapOfIntegerInteger, TColStd_DataMapOfIntegerListOfInteger, TColStd_DataMapOfIntegerReal, TColStd_IndexedDataMapOfTransientTransient, TColStd_IndexedMapOfInteger, TColStd_IndexedMapOfReal, TColStd_IndexedMapOfTransient, TColStd_MapOfInteger, TColStd_MapOfReal, TColStd_MapOfTransient, TColStd_PackedMapOfInteger, TopLoc_IndexedMapOfLocation, and TopLoc_MapOfLocation.

void* TCollection_BasicMap::operator new | ( | size_t | size | ) | `[inline]`

Reimplemented in Expr_MapOfNamedUnknown, GraphDS_EntityRoleMap, Plugin_MapOfFunctions, Resource_DataMapOfAsciiStringAsciiString, Resource_DataMapOfAsciiStringExtendedString, Storage_MapOfAsciiString, Storage_MapOfCallBack, Storage_MapOfPers, Storage_PType, TColgp_DataMapOfIntegerCirc2d, TColStd_DataMapOfIntegerInteger, TColStd_DataMapOfIntegerListOfInteger, TColStd_DataMapOfIntegerReal, TColStd_IndexedDataMapOfTransientTransient, TColStd_IndexedMapOfInteger, TColStd_IndexedMapOfReal, TColStd_IndexedMapOfTransient, TColStd_MapOfInteger, TColStd_MapOfReal, TColStd_MapOfTransient, TColStd_PackedMapOfInteger, TopLoc_IndexedMapOfLocation, and TopLoc_MapOfLocation.

void* TCollection_BasicMap::operator new | ( | size_t | ,
|  | void * | anAddress
| ) | `[inline]`

Reimplemented in Expr_MapOfNamedUnknown, GraphDS_EntityRoleMap, Plugin_MapOfFunctions, Resource_DataMapOfAsciiStringAsciiString, Resource_DataMapOfAsciiStringExtendedString, Storage_MapOfAsciiString, Storage_MapOfCallBack, Storage_MapOfPers, Storage_PType, TColgp_DataMapOfIntegerCirc2d, TColStd_DataMapOfIntegerInteger, TColStd_DataMapOfIntegerListOfInteger, TColStd_DataMapOfIntegerReal, TColStd_IndexedDataMapOfTransientTransient, TColStd_IndexedMapOfInteger, TColStd_IndexedMapOfReal, TColStd_IndexedMapOfTransient, TColStd_MapOfInteger, TColStd_MapOfReal, TColStd_MapOfTransient, TopLoc_IndexedMapOfLocation, and TopLoc_MapOfLocation.

Standard_Boolean TCollection_BasicMap::Resizable | ( |  | ) | const`[inline, protected]`

Standard_EXPORT void TCollection_BasicMap::Statistics | ( | Standard_OStream & | S | ) | const

| Reimplemented in TColStd_PackedMapOfInteger.

## Field Documentation

Standard_Boolean TCollection_BasicMap::isDouble `[private]`

Standard_Address TCollection_BasicMap::myData1 `[protected]`

Standard_Address TCollection_BasicMap::myData2 `[protected]`

Standard_Integer TCollection_BasicMap::myNbBuckets `[private]`

Standard_Boolean TCollection_BasicMap::mySaturated `[private]`

Standard_Integer TCollection_BasicMap::mySize `[private]`

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

- TCollection_BasicMap.hxx
- TCollection_BasicMap.lxx