Export (0) Print
Expand All

CSimpleMap Class

This class provides support for a simple mapping array.

template <  
   class TKey, 
   class TVal, 
   class TEqual = CSimpleMapEqualHelper< TKey, TVal >  
>  
class CSimpleMap

TKey

The key element type.

TVal

The value element type.

TEqual

A trait object, defining the equality test for elements of type T.

Name

Description

CSimpleMap::_ArrayElementType

Typedef for the value type.

CSimpleMap::_ArrayKeyType

Typedef for the key type.

Name

Description

CSimpleMap::CSimpleMap

The constructor.

CSimpleMap::~CSimpleMap

The destructor.

Name

Description

CSimpleMap::Add

Adds a key and associated value to the map array.

CSimpleMap::FindKey

Finds a specific key.

CSimpleMap::FindVal

Finds a specific value.

CSimpleMap::GetKeyAt

Retrieves the specified key.

CSimpleMap::GetSize

Returns the number of entries in the mapping array.

CSimpleMap::GetValueAt

Retrieves the specified value.

CSimpleMap::Lookup

Returns the value associated with the given key.

CSimpleMap::Remove

Removes a key and matching value.

CSimpleMap::RemoveAll

Removes all keys and values.

CSimpleMap::RemoveAt

Removes a specific key and matching value.

CSimpleMap::ReverseLookup

Returns the key associated with the given value.

CSimpleMap::SetAt

Sets the value associated with the given key.

CSimpleMap::SetAtIndex

Sets the specific key and value.

CSimpleMap provides support for a simple mapping array of any given type T, managing an unordered array of key elements and their associated values.

The parameter TEqual provides a means of defining an equality function for two elements of type T. By creating a class similar to CSimpleMapEqualHelper, it is possible to alter the behavior of the equality test for any given array. For example, when dealing with an array of pointers, it may be useful to define the equality as depending on the values the pointers reference. The default implementation utilizes operator==().

Both CSimpleMap and CSimpleArray are provided for compatibility with previous ATL releases, and more complete and efficient collection implementations are provided by CAtlArray and CAtlMap.

Unlike other map collections in ATL and MFC, this class is implemented with a simple array, and lookup searches require a linear search. CAtlMap should be used when the array contains a large number of elements.

Header: atlsimpcoll.h

// Create a map with an integer key and character pointer value
CSimpleMap<int, char *> iArray;   
Show:
© 2014 Microsoft