iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::AutoMap< KeyType, ValueType > Class Template Reference

#include <nrt/Core/Design/AutoMap.H>

template<class KeyType, class ValueType>
class nrt::AutoMap< KeyType, ValueType >

A table used to create unique Ids and store a value for each Id.

The AutoMap class provides a way to create unique keys, with recycling when keys get deleted. One can then store a value for each key. The keys are unique to each instance of the class, not globally unique.

Note
Care must be taken when using this structure in a multithreaded environment. If not locked properly, the internal structures could get messed up. AutoMap itself has no internal locking mechanisms.

Definition at line 60 of file AutoMap.H.

Public Types

typedef std::map< KeyType,
ValueType >::iterator 
iterator
 Iterator over the map.
 
typedef std::map< KeyType,
ValueType >::const_iterator 
const_iterator
 Constant iterator over the map.
 

Public Member Functions

 AutoMap ()
 Constructor.
 
iterator begin ()
 Returns an iterator pointing to the beginning of the map.
 
iterator end ()
 Returns an iterator pointing to the end of the map.
 
const_iterator begin () const
 Returns a const_iterator pointing to the beginning of the map.
 
const_iterator end () const
 Returns an iterator pointing to the end of the map.
 
ValueType & operator[] (KeyType const &key)
 Access a value by key. More...
 
KeyType insert (ValueType const &value)
 Insert a value by first creating a new key for it, and return that key. More...
 
void erase (iterator pos)
 Erase a key/value entry from the map.
 
void erase (KeyType const &key)
 Erase by key, it will be recycled and available next time a new key is created by insert()
 
void clear ()
 Clear the entire AutoMap.
 

Member Function Documentation

template<class KeyType, class ValueType >
ValueType & nrt::AutoMap< KeyType, ValueType >::operator[] ( KeyType const &  key)
inline

Access a value by key.

Caution this is different from std::map and will throw if the key does not exist.

Definition at line 84 of file AutoMapImpl.H.

template<class KeyType , class ValueType>
KeyType nrt::AutoMap< KeyType, ValueType >::insert ( ValueType const &  value)
inline

Insert a value by first creating a new key for it, and return that key.

This is the function that std::map is missing.

Definition at line 95 of file AutoMapImpl.H.


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