Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
StlMap< Key, Value > Class Template Reference

Though at the surface, this may seem like an unnecessary abstraction of std::map, it has the purpose of limiting the implementation to features found only in common to SysMap and LinearMap implementations. More...

#include <StlMap.hxx>

Public Types

typedef pair< Key, Value > Pair
 This translation is done for consistency with SysMap and LinearMap.
 
typedef std::map< Key, Value >::iterator Iterator
 Short hand for the iterator type of a given instance.
 

Public Member Functions

 StlMap ()
 Default Constructor which with no mapping entry limit.
 
 StlMap (size_t entries)
 Constructor that limits the number of mappings to a static pool.
 
 ~StlMap ()
 Destructor.
 
void clear ()
 Removes all elements in the map.
 
size_t erase (Key key)
 Remove an element from the tree.
 
void erase (Iterator it)
 Remove a node from the tree.
 
Value & operator[] (const Key &key)
 Find the index associated with the key and create it if does not exist.
 
size_t size ()
 Number of elements currently in the map.
 
size_t max_size ()
 Maximum theoretical number of elements in the map.
 
Iterator find (const Key &key)
 Find an element matching the given key.
 
Iterator end ()
 Get an iterator index pointing one past the last element in mapping.
 
Iterator begin ()
 Get an iterator index pointing one past the last element in mapping.
 

Private Types

typedef std::map< Key, Value, std::less< Key >, Allocator< std::pair< const Key, Value > > > MappingAllocator
 short hand for the custom allocator std::map type
 
typedef std::map< Key, Value > Mapping
 short hand for the default allocator std::map type
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (StlMap)
 

Private Attributes

MappingAllocatormappingAllocator
 pointer to an std::map instance with a custom allocator
 
Mappingmapping
 pointer to an std::map instance with a default allocator
 

Detailed Description

template<typename Key, typename Value>
class StlMap< Key, Value >

Though at the surface, this may seem like an unnecessary abstraction of std::map, it has the purpose of limiting the implementation to features found only in common to SysMap and LinearMap implementations.

In this way, one can use Map and based on compile time settings choose to use any one of StlMap, SysMap, or LinearMap from the same source usage of Map.

Definition at line 49 of file StlMap.hxx.

Member Typedef Documentation

◆ Iterator

template<typename Key , typename Value >
typedef std::map<Key,Value>::iterator StlMap< Key, Value >::Iterator

Short hand for the iterator type of a given instance.

Definition at line 87 of file StlMap.hxx.

◆ Mapping

template<typename Key , typename Value >
typedef std::map<Key, Value> StlMap< Key, Value >::Mapping
private

short hand for the default allocator std::map type

Definition at line 170 of file StlMap.hxx.

◆ MappingAllocator

template<typename Key , typename Value >
typedef std::map<Key, Value, std::less<Key>, Allocator<std::pair<const Key, Value> > > StlMap< Key, Value >::MappingAllocator
private

short hand for the custom allocator std::map type

Definition at line 167 of file StlMap.hxx.

◆ Pair

template<typename Key , typename Value >
typedef pair<Key, Value> StlMap< Key, Value >::Pair

This translation is done for consistency with SysMap and LinearMap.

Definition at line 84 of file StlMap.hxx.

Constructor & Destructor Documentation

◆ StlMap() [1/2]

template<typename Key , typename Value >
StlMap< Key, Value >::StlMap ( )
inline

Default Constructor which with no mapping entry limit.

Definition at line 54 of file StlMap.hxx.

◆ StlMap() [2/2]

template<typename Key , typename Value >
StlMap< Key, Value >::StlMap ( size_t  entries)
inline

Constructor that limits the number of mappings to a static pool.

Parameters
entriesnumber of nodes to statically create and track

Definition at line 63 of file StlMap.hxx.

◆ ~StlMap()

template<typename Key , typename Value >
StlMap< Key, Value >::~StlMap ( )
inline

Destructor.

Definition at line 71 of file StlMap.hxx.

Member Function Documentation

◆ begin()

template<typename Key , typename Value >
Iterator StlMap< Key, Value >::begin ( )
inline

Get an iterator index pointing one past the last element in mapping.

Returns
iterator index pointing to one past the last element in mapping

Definition at line 160 of file StlMap.hxx.

◆ clear()

template<typename Key , typename Value >
void StlMap< Key, Value >::clear ( )
inline

Removes all elements in the map.

Definition at line 90 of file StlMap.hxx.

◆ end()

template<typename Key , typename Value >
Iterator StlMap< Key, Value >::end ( )
inline

Get an iterator index pointing one past the last element in mapping.

Returns
iterator index pointing to one past the last element in mapping

Definition at line 152 of file StlMap.hxx.

◆ erase() [1/2]

template<typename Key , typename Value >
void StlMap< Key, Value >::erase ( Iterator  it)
inline

Remove a node from the tree.

Parameters
ititerator index for the element to remove

Definition at line 110 of file StlMap.hxx.

◆ erase() [2/2]

template<typename Key , typename Value >
size_t StlMap< Key, Value >::erase ( Key  key)
inline

Remove an element from the tree.

Parameters
keykey for the element to remove
Returns
number of elements removed

Definition at line 102 of file StlMap.hxx.

◆ find()

template<typename Key , typename Value >
Iterator StlMap< Key, Value >::find ( const Key &  key)
inline

Find an element matching the given key.

Parameters
keykey to search for
Returns
iterator index pointing to key, else iterator end() if not found

Definition at line 144 of file StlMap.hxx.

◆ max_size()

template<typename Key , typename Value >
size_t StlMap< Key, Value >::max_size ( )
inline

Maximum theoretical number of elements in the map.

Returns
maximum theoretical number of elements in the map

Definition at line 135 of file StlMap.hxx.

◆ operator[]()

template<typename Key , typename Value >
Value & StlMap< Key, Value >::operator[] ( const Key &  key)
inline

Find the index associated with the key and create it if does not exist.

Parameters
keykey to lookup
Returns
value of the key by reference

Definition at line 119 of file StlMap.hxx.

◆ size()

template<typename Key , typename Value >
size_t StlMap< Key, Value >::size ( )
inline

Number of elements currently in the map.

Returns
number of elements in the map

Definition at line 127 of file StlMap.hxx.

Member Data Documentation

◆ mapping

template<typename Key , typename Value >
Mapping* StlMap< Key, Value >::mapping
private

pointer to an std::map instance with a default allocator

Definition at line 176 of file StlMap.hxx.

◆ mappingAllocator

template<typename Key , typename Value >
MappingAllocator* StlMap< Key, Value >::mappingAllocator
private

pointer to an std::map instance with a custom allocator

Definition at line 173 of file StlMap.hxx.


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