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

This is an abstraction of BSD sys/tree.h that is meant to mimic the semantics of std::map without having to link in libstdc++. More...

#include <LinearMap.hxx>

Classes

struct  Element
 Entry element in mapping. More...
 
class  Iterator
 This mimics an std::Iterator. More...
 
struct  Pair
 list entry. More...
 

Public Member Functions

 LinearMap ()
 Default Constructor which with no mapping entry limit.
 
 LinearMap (size_t entries)
 Constructor that limits the number of mappings to a static pool.
 
 ~LinearMap ()
 Destructor.
 
void clear ()
 Removes all elements.
 
size_t erase (Key key)
 Remove a node 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 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 to the first element in the mapping.
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (LinearMap)
 

Private Attributes

size_t entries
 total number of entries for this instance
 
size_t used
 total number of entries in use for this instance
 
Elementlist
 list of entries
 

Detailed Description

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

This is an abstraction of BSD sys/tree.h that is meant to mimic the semantics of std::map without having to link in libstdc++.

Definition at line 45 of file LinearMap.hxx.

Constructor & Destructor Documentation

◆ LinearMap() [1/2]

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

Default Constructor which with no mapping entry limit.

Definition at line 50 of file LinearMap.hxx.

◆ LinearMap() [2/2]

template<typename Key , typename Value >
LinearMap< Key, Value >::LinearMap ( 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 62 of file LinearMap.hxx.

◆ ~LinearMap()

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

Destructor.

Definition at line 71 of file LinearMap.hxx.

Member Function Documentation

◆ begin()

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

Get an Iterator index pointing to the first element in the mapping.

Returns
Iterator index pointing to the first element in the mapping or to end() if the mapping is empty

Definition at line 293 of file LinearMap.hxx.

◆ clear()

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

Removes all elements.

Definition at line 184 of file LinearMap.hxx.

◆ end()

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

◆ erase() [1/2]

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

Remove a node from the tree.

Parameters
itIterator index for the element to remove

Definition at line 214 of file LinearMap.hxx.

◆ erase() [2/2]

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

Remove a node from the tree.

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

Definition at line 193 of file LinearMap.hxx.

◆ find()

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

◆ max_size()

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

◆ operator[]()

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

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

Parameters
keykey to lookup
Returns
value of the key by reference

Definition at line 231 of file LinearMap.hxx.

◆ size()

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

Number of elements currently in the map.

Returns
number of elements in the map

Definition at line 252 of file LinearMap.hxx.

Member Data Documentation

◆ entries

template<typename Key , typename Value >
size_t LinearMap< Key, Value >::entries
private

total number of entries for this instance

Definition at line 300 of file LinearMap.hxx.

◆ list

template<typename Key , typename Value >
Element* LinearMap< Key, Value >::list
private

list of entries

Definition at line 306 of file LinearMap.hxx.

◆ used

template<typename Key , typename Value >
size_t LinearMap< Key, Value >::used
private

total number of entries in use for this instance

Definition at line 303 of file LinearMap.hxx.


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