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

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

#include <StlMultiMap.hxx>

Public Types

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

Public Member Functions

 StlMultiMap ()
 Default Constructor which with no mapping entry limit.
 
 StlMultiMap (size_t entries)
 Constructor that limits the number of mappings to a static pool.
 
 ~StlMultiMap ()
 Destructor.
 
size_t erase (Key key)
 Remove an element from the tree.
 
void erase (Iterator it)
 Remove a node from the tree.
 
Iterator insert (const Iterator pos, const Pair &val)
 Insert (create) a new key value pair.
 
Iterator insert (const Pair &val)
 Insert (create) a new key value pair.
 
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 lower_bound (const Key &key)
 Get an iterator pointing the the first element in the map with the provided key, else iterator end() if not found.
 
Iterator upper_bound (const Key &key)
 Get an iterator pointing the the first element in the map after the provided 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.
 
size_t count (const Key &key) const
 Get the count of elements with a givin Key.
 

Private Types

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

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (StlMultiMap)
 

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 StlMultiMap< Key, Value >

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

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

Definition at line 49 of file StlMultiMap.hxx.

Member Typedef Documentation

◆ Iterator

template<typename Key , typename Value >
typedef std::multimap<Key,Value>::iterator StlMultiMap< Key, Value >::Iterator

Short hand for the iterator type of a given instance.

Definition at line 87 of file StlMultiMap.hxx.

◆ Mapping

template<typename Key , typename Value >
typedef std::multimap<Key, Value> StlMultiMap< Key, Value >::Mapping
private

short hand for the default allocator std::map type

Definition at line 200 of file StlMultiMap.hxx.

◆ MappingAllocator

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

short hand for the custom allocator std::map type

Definition at line 197 of file StlMultiMap.hxx.

◆ Pair

template<typename Key , typename Value >
typedef std::pair<Key, Value> StlMultiMap< Key, Value >::Pair

This translation is done for consistency with SysMap and LinearMap.

Definition at line 84 of file StlMultiMap.hxx.

Constructor & Destructor Documentation

◆ StlMultiMap() [1/2]

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

Default Constructor which with no mapping entry limit.

Definition at line 54 of file StlMultiMap.hxx.

◆ StlMultiMap() [2/2]

template<typename Key , typename Value >
StlMultiMap< Key, Value >::StlMultiMap ( 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 StlMultiMap.hxx.

◆ ~StlMultiMap()

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

Destructor.

Definition at line 71 of file StlMultiMap.hxx.

Member Function Documentation

◆ begin()

template<typename Key , typename Value >
Iterator StlMultiMap< 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 181 of file StlMultiMap.hxx.

◆ count()

template<typename Key , typename Value >
size_t StlMultiMap< Key, Value >::count ( const Key &  key) const
inline

Get the count of elements with a givin Key.

Parameters
keykey for the elements to count
Returns
number of elements with a givin key

Definition at line 190 of file StlMultiMap.hxx.

◆ end()

template<typename Key , typename Value >
Iterator StlMultiMap< 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 173 of file StlMultiMap.hxx.

◆ erase() [1/2]

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

Remove a node from the tree.

Parameters
ititerator index for the element to remove

Definition at line 101 of file StlMultiMap.hxx.

◆ erase() [2/2]

template<typename Key , typename Value >
size_t StlMultiMap< 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 93 of file StlMultiMap.hxx.

◆ find()

template<typename Key , typename Value >
Iterator StlMultiMap< 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 145 of file StlMultiMap.hxx.

◆ insert() [1/2]

template<typename Key , typename Value >
Iterator StlMultiMap< Key, Value >::insert ( const Iterator  pos,
const Pair val 
)
inline

Insert (create) a new key value pair.

Parameters
poshint as to the position to which to place the new mapping
valKey, Value Pair to insert into the mapping
Returns
Iterator pointing to new or exising Key, Value Pair

Definition at line 111 of file StlMultiMap.hxx.

◆ insert() [2/2]

template<typename Key , typename Value >
Iterator StlMultiMap< Key, Value >::insert ( const Pair val)
inline

Insert (create) a new key value pair.

Parameters
valKey, Value Pair to insert into the mapping
Returns
Iterator pointing to new or exising Key, Value Pair

Definition at line 120 of file StlMultiMap.hxx.

◆ lower_bound()

template<typename Key , typename Value >
Iterator StlMultiMap< Key, Value >::lower_bound ( const Key &  key)
inline

Get an iterator pointing the the first element in the map with the provided key, else iterator end() if not found.

Parameters
keykey for the elements to lower bound
Returns
iterator pointing to first element with the provided key

Definition at line 155 of file StlMultiMap.hxx.

◆ max_size()

template<typename Key , typename Value >
size_t StlMultiMap< 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 136 of file StlMultiMap.hxx.

◆ size()

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

Number of elements currently in the map.

Returns
number of elements in the map

Definition at line 128 of file StlMultiMap.hxx.

◆ upper_bound()

template<typename Key , typename Value >
Iterator StlMultiMap< Key, Value >::upper_bound ( const Key &  key)
inline

Get an iterator pointing the the first element in the map after the provided key.

Parameters
keykey for the elements to upper bound
Returns
iterator pointing to first element after the provided key

Definition at line 165 of file StlMultiMap.hxx.

Member Data Documentation

◆ mapping

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

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

Definition at line 206 of file StlMultiMap.hxx.

◆ mappingAllocator

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

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

Definition at line 203 of file StlMultiMap.hxx.


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