xorp

ConfigNodeIdMap< V > Class Template Reference

Class for storing the mapping between a ConfigNodeId node and the corresponding value. More...

#include <config_node_id.hh>

List of all members.

Public Types

typedef list< pair
< ConfigNodeId, V > > 
ValuesList
typedef ValuesList::iterator iterator
typedef ValuesList::const_iterator const_iterator

Public Member Functions

 ConfigNodeIdMap ()
 Default constructor.
virtual ~ConfigNodeIdMap ()
 Destructor.
ConfigNodeIdMap::iterator begin ()
 Get the iterator to the first element.
ConfigNodeIdMap::const_iterator begin () const
 Get the const iterator to the first element.
ConfigNodeIdMap::iterator end ()
 Get the iterator to the last element.
ConfigNodeIdMap::const_iterator end () const
 Get the const iterator to the last element.
ConfigNodeIdMap::iterator find (const ConfigNodeId &node_id)
 Find an element for a given node ID.
ConfigNodeIdMap::const_iterator find (const ConfigNodeId &node_id) const
 Find an element for a given node ID.
pair< iterator, bool > insert (const ConfigNodeId &node_id, const V &v)
 Insert a new element.
pair< iterator, bool > insert_out_of_order (const ConfigNodeId &node_id, const V &v)
 Insert a new element that might be out-of-order.
size_t erase (const ConfigNodeId &node_id)
 Remove an existing element.
void erase (ConfigNodeIdMap::iterator iter)
 Remove an existing element.
void clear ()
 Remove all elements.
string str () const
 Convert this object from binary form to presentation format.
size_t size () const
 Get the number of elements in the storage.
bool empty () const
 Test if the container is empty.

Private Types

typedef map
< ConfigNodeId::UniqueNodeId,
iterator > 
NodeId2IterMap

Private Member Functions

pair< iterator, bool > insert_impl (const ConfigNodeId &node_id, const V &v, bool ignore_missing_previous_element)
 Insert a new element.

Private Attributes

NodeId2IterMap _node_id2iter
ValuesList _values_list

Detailed Description

template<typename V>
class ConfigNodeIdMap< V >

Class for storing the mapping between a ConfigNodeId node and the corresponding value.

Internally the class is implemented as a mapped linked list:

  • A linked list of pairs <ConfigNodeId, typename V> contains the ConfigNodeId nodes and the corresponding values.
  • An STL <map> stores the mapping between unique node IDs and the corresponding iterators in the above list.

The advantage of such implementation is that the time to insert and remove entries to/from the list is similar to the time to perform those operations on an STL map container.


Member Function Documentation

template<typename V>
ConfigNodeIdMap::iterator ConfigNodeIdMap< V >::begin ( ) [inline]

Get the iterator to the first element.

Returns:
the iterator to the first element.
template<typename V>
ConfigNodeIdMap::const_iterator ConfigNodeIdMap< V >::begin ( ) const [inline]

Get the const iterator to the first element.

Returns:
the const iterator to the first element.
template<typename V>
bool ConfigNodeIdMap< V >::empty ( ) const [inline]

Test if the container is empty.

Returns:
true if the container is empty, otherwise false.
template<typename V>
ConfigNodeIdMap::const_iterator ConfigNodeIdMap< V >::end ( ) const [inline]

Get the const iterator to the last element.

Returns:
the const iterator to the last element.
template<typename V>
ConfigNodeIdMap::iterator ConfigNodeIdMap< V >::end ( ) [inline]

Get the iterator to the last element.

Returns:
the iterator to the last element.
template<typename V >
size_t ConfigNodeIdMap< V >::erase ( const ConfigNodeId node_id) [inline]

Remove an existing element.

Parameters:
node_idthe node ID of the element to remove.
Returns:
the number of removed elements.
template<typename V >
void ConfigNodeIdMap< V >::erase ( ConfigNodeIdMap< V >::iterator  iter) [inline]

Remove an existing element.

Parameters:
iterthe iterator to the element to remove.
template<typename V >
ConfigNodeIdMap< V >::iterator ConfigNodeIdMap< V >::find ( const ConfigNodeId node_id) [inline]

Find an element for a given node ID.

Parameters:
node_idthe node ID to search for.
Returns:
the iterator to the element.
template<typename V >
ConfigNodeIdMap< V >::const_iterator ConfigNodeIdMap< V >::find ( const ConfigNodeId node_id) const [inline]

Find an element for a given node ID.

Parameters:
node_idthe node ID to search for.
Returns:
the const iterator to the element.
template<typename V>
pair<iterator, bool> ConfigNodeIdMap< V >::insert ( const ConfigNodeId node_id,
const V &  v 
) [inline]

Insert a new element.

Parameters:
node_idthe node ID of the element to insert.
vthe value of the element to insert.
Returns:
true a pair of two values: iterator and a boolean flag. If the boolean flag is true, the element was inserted successfully, and the iterator points to the new element. If the boolean flag is false, then either there is an element with the same node ID, and the iterator points to that element, or the element could not be inserted because of invalid node ID and the iterator points to end() of the container.
template<typename V>
pair< typename ConfigNodeIdMap< V >::iterator, bool > ConfigNodeIdMap< V >::insert_impl ( const ConfigNodeId node_id,
const V &  v,
bool  ignore_missing_previous_element 
) [inline, private]

Insert a new element.

Parameters:
node_idthe node ID of the element to insert.
vthe value of the element to insert.
ignore_missing_previous_elementif true, and the previous element is not found, then insert the element at the end of the container. If this flag is false and the previous element is not found, then don't insert the element, but return an error.
Returns:
true a pair of two values: iterator and a boolean flag. If the boolean flag is true, the element was inserted successfully, and the iterator points to the new element. If the boolean flag is false, then either there is an element with the same node ID, and the iterator points to that element, or the element could not be inserted because of invalid node ID and the iterator points to end() of the container.
template<typename V>
pair<iterator, bool> ConfigNodeIdMap< V >::insert_out_of_order ( const ConfigNodeId node_id,
const V &  v 
) [inline]

Insert a new element that might be out-of-order.

Parameters:
node_idthe node ID of the element to insert.
vthe value of the element to insert.
Returns:
true a pair of two values: iterator and a boolean flag. If the boolean flag is true, the element was inserted successfully, and the iterator points to the new element. If the boolean flag is false, then there is an element with the same node ID, and the iterator points to that element.
template<typename V>
size_t ConfigNodeIdMap< V >::size ( ) const [inline]

Get the number of elements in the storage.

Returns:
the number of elements in the storage.
template<typename V >
string ConfigNodeIdMap< V >::str ( ) const [inline]

Convert this object from binary form to presentation format.

Returns:
C++ string with the human-readable ASCII representation of the object.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations