NMap Class Template Reference

NMap class provides a skip-list based dictionary. More...

List of all members.

Public Types

typedef const iterator const_iterator

Public Member Functions

 NMap (void)
 Constructs a NMap object.
 ~NMap (void)
 Destroys a NMap object.
bool contains (const K &keyname) const
 Returns whether there is an item.
bool contains (const K &keyname, const V &val) const
 Returns whether there is an item.
nuint64 size (void) const
 Gets the current number of itens in the map.
nuint64 count (void) const
 Gets the current number of itens in the map.
nuint64 count (const K &keyname) const
 Gets the count of itens in the list that are equal to a given keyname.
iterator begin (void)
 Returns an iterator pointing to the first item in the map.
const_iterator constBegin (void) const
 Returns a const_iterator pointing to the first item in the map.
iterator end (void)
 Returns an iterator pointing to the last item in the map.
const_iterator constEnd (void) const
 Returns a const_iterator pointing to the last item in the map.
bool erase (iterator pos)
 Removes the item defined by key from the map. If it is not found it will be silently ignored.
iterator find (const K &keyname)
 Finds a node containing key.
iterator find (const K &keyname, const V &val)
 Finds a node containing key.
const_iterator constFind (const K &keyname) const
 Finds a node containing key.
const_iterator constFind (const K &keyname, const V &val) const
 Finds a node containing key.
iterator insert (const K &keyname, const V &val)
 Inserts the data defined by key in the list and val.
bool isEmpty (void) const
 Checks whether the map is empty.
const K key (const V val) const
 Gets the first key containing a given value.
NList< K > keys (void) const
 Gets a list of the keys in the map.
NList< K > keys (const V val)
 Gets a list of the keys in the map that contains a given value.
nuint64 remove (const K &keyname)
 Removes the itens containing a given key name.
take (const K &keyname)
 Removes the a item with a given key value in the map and returns it.
value (const K &keyname) const
 Gets the value of a given key.
value (const K &keyname, const V &defaultValue) const
 Gets the value of a given key.
NList< V > values (void) const
 Gets a list of values in the map.
NList< V > values (const K &keyname) const
 Gets a list of values in the map with a given keyname.
void clear (void)
 Clears the map.
void copy (const NMap< K, V > &rhs)
 Copies another map.
NMap< K, V > & operator= (const NMap< K, V > &rhs)
 Copies another map.
bool operator!= (const NMap< K, V > &rhs) const
 Tests whether a map differs from another.
bool operator== (const NMap< K, V > &rhs) const
 Tests whether a map equals another.
operator[] (const K &keyname)
 Gets the value of a given key.
const V & operator[] (const K &keyname) const
 Gets the value of a given key.

Classes

class  iterator
 NMap::iterator class provides an iterator to navigate through the map object. More...


Detailed Description

template<typename K, typename V>
class NMap< K, V >

NMap class provides a skip-list based dictionary.

Todo:
remove(const K &key) Could be optimized. Improve NSkipList's erase first, though
Todo:
Document NMap
Examples:

ex_nmap.cpp.

Definition at line 36 of file nmap.hpp.


Member Typedef Documentation

typedef const iterator const_iterator

NMap iterator

Definition at line 38 of file nmap.hpp.


Member Function Documentation

bool contains ( const K &  keyname  )  const [inline]

Returns whether there is an item.

Parameters:
keyname The keyname of the item to search
Returns:
True if there is an item equal to val or false otherwise

Definition at line 721 of file nmap.hpp.

References constEnd(), and constFind().

Referenced by NSqlRecord::getData(), operator!=(), and operator==().

bool contains ( const K &  keyname,
const V &  val 
) const [inline]

Returns whether there is an item.

Parameters:
keyname The keyname of the item to search
val The value of the item to search
Returns:
True if there is an item equal to val or false otherwise

Definition at line 731 of file nmap.hpp.

References constEnd(), and constFind().

nuint64 size ( void   )  const [inline]

Gets the current number of itens in the map.

Returns:
The current number of itens in the map
Note:
See count()

Definition at line 304 of file nmap.hpp.

References NSkipList::count().

nuint64 count ( void   )  const [inline]

Gets the current number of itens in the map.

Returns:
The current number of itens in the map

Definition at line 310 of file nmap.hpp.

References NSkipList::count().

nuint64 count ( const K &  keyname  )  const [inline]

Gets the count of itens in the list that are equal to a given keyname.

Parameters:
keyname The name of the key
Returns:
The count of itens in the map that are equal to a given key
Note:
Note that the 'keyname' object must implement operator==

Definition at line 316 of file nmap.hpp.

References NSkipList::begin(), and NSkipList::end().

NMap< K, V >::iterator begin ( void   )  [inline]

Returns an iterator pointing to the first item in the map.

Returns:
An iterator pointing to the first item in the map

Definition at line 473 of file nmap.hpp.

References NSkipList::begin().

Referenced by copy(), operator!=(), operator==(), NEvent1::~NEvent1(), and NSignal1::~NSignal1().

NMAPITERATOR_CONST constBegin ( void   )  const [inline]

Returns a const_iterator pointing to the first item in the map.

Returns:
A const_iterator pointing to the first item in the map

Definition at line 479 of file nmap.hpp.

References NSkipList::constBegin().

Referenced by NEvent1::notify().

NMap< K, V >::iterator end ( void   )  [inline]

Returns an iterator pointing to the last item in the map.

Returns:
An iterator pointing to the last item in the map

Definition at line 487 of file nmap.hpp.

References NSkipList::end().

Referenced by copy(), NEvent1::detach(), NEvent1::isAttached(), operator!=(), operator==(), NEvent1::~NEvent1(), and NSignal1::~NSignal1().

NMAPITERATOR_CONST constEnd ( void   )  const [inline]

Returns a const_iterator pointing to the last item in the map.

Returns:
A const_iterator pointing to the last item in the map

Definition at line 493 of file nmap.hpp.

References NSkipList::constEnd().

Referenced by contains(), and NEvent1::notify().

bool erase ( iterator  pos  )  [inline]

Removes the item defined by key from the map. If it is not found it will be silently ignored.

Parameters:
pos An iterator pointing to the item to be removed
Returns:
true if succeeded removing the item of false otherwise

Definition at line 499 of file nmap.hpp.

References NSkipList::erase().

Referenced by NEvent1::detach().

NMap< K, V >::iterator find ( const K &  keyname  )  [inline]

Finds a node containing key.

Parameters:
keyname The key to be searched
Returns:
An iterator pointing to key or end() if not found

Definition at line 505 of file nmap.hpp.

References NSkipList::begin(), and NSkipList::end().

Referenced by NEvent1::detach(), and NEvent1::isAttached().

NMap< K, V >::iterator find ( const K &  keyname,
const V &  val 
) [inline]

Finds a node containing key.

Parameters:
keyname The key to be searched
val The value of the item to be searched
Returns:
A const iterator pointing to key or end() if not found

Definition at line 533 of file nmap.hpp.

References NSkipList::begin(), and NSkipList::end().

NMAPITERATOR_CONST constFind ( const K &  keyname  )  const [inline]

Finds a node containing key.

Parameters:
keyname The key to be searched
Returns:
A const iterator pointing to key or end() if not found

Definition at line 518 of file nmap.hpp.

References NSkipList::constBegin(), and NSkipList::constEnd().

Referenced by contains().

NMAPITERATOR_CONST constFind ( const K &  keyname,
const V &  val 
) const [inline]

Finds a node containing key.

Parameters:
keyname The key to be searched
val The value of the item to be searched
Returns:
A const iterator pointing to key or end() if not found

Definition at line 545 of file nmap.hpp.

References NSkipList::constBegin(), and NSkipList::constEnd().

NMap< K, V >::iterator insert ( const K &  keyname,
const V &  val 
) [inline]

Inserts the data defined by key in the list and val.

Parameters:
keyname The key of the item to be added to the map
val The value of the item to be added to the map
Returns:
An iterator pointing to key of end() if already exists
Note:
If it is already in the list it will be silently ignored

Definition at line 559 of file nmap.hpp.

References NSkipList::insert(), NMapItem::key, and NMapItem::value.

Referenced by NEvent1::attach(), NSignal1::connect(), and copy().

bool isEmpty ( void   )  const [inline]

Checks whether the map is empty.

Returns:
true if it is empty or false otherwise

Definition at line 569 of file nmap.hpp.

References NSkipList::isEmpty().

const K key ( const V  val  )  const [inline]

Gets the first key containing a given value.

Parameters:
val The value of the item
Returns:
The found key or a default constructed value if not found

Definition at line 575 of file nmap.hpp.

References NSkipList::begin(), and NSkipList::end().

NList< K > keys ( void   )  const [inline]

Gets a list of the keys in the map.

Returns:
The list of the keys in the map

Definition at line 590 of file nmap.hpp.

References NList::append(), NSkipList::constBegin(), and NSkipList::constEnd().

NList< K > keys ( const V  val  )  [inline]

Gets a list of the keys in the map that contains a given value.

Returns:
The list of the keys in the map

Definition at line 605 of file nmap.hpp.

References NList::append(), NSkipList::begin(), and NSkipList::end().

nuint64 remove ( const K &  keyname  )  [inline]

Removes the itens containing a given key name.

Parameters:
keyname The value of the key
Returns:
The number of the itens removed

Definition at line 620 of file nmap.hpp.

References NSkipList::begin(), and NSkipList::end().

V take ( const K &  keyname  )  [inline]

Removes the a item with a given key value in the map and returns it.

Returns:
The item in the map or a default constructed value if it does not exists

Definition at line 635 of file nmap.hpp.

References NSkipList::begin(), and NSkipList::end().

V value ( const K &  keyname  )  const [inline]

Gets the value of a given key.

Parameters:
keyname The value of the key
Returns:
The value or a default constructed value if not found

Definition at line 648 of file nmap.hpp.

References NSkipList::constBegin(), and NSkipList::constEnd().

Referenced by NSqlRecord::getData(), and operator[]().

V value ( const K &  keyname,
const V &  defaultValue 
) const [inline]

Gets the value of a given key.

Parameters:
keyname The value of the key
defaultValue The default value for the return object, if not found
Returns:
The value or a defaultValue if not found

Definition at line 665 of file nmap.hpp.

References NSkipList::constBegin(), and NSkipList::constEnd().

NList< V > values ( void   )  const [inline]

Gets a list of values in the map.

Returns:
A NList object with the values in the map

Definition at line 682 of file nmap.hpp.

References NList::append(), NSkipList::constBegin(), and NSkipList::constEnd().

NList< V > values ( const K &  keyname  )  const [inline]

Gets a list of values in the map with a given keyname.

Parameters:
keyname The value of the key
Returns:
A NList object with the values in the map

Definition at line 695 of file nmap.hpp.

References NList::append(), NSkipList::constBegin(), and NSkipList::constEnd().

void copy ( const NMap< K, V > &  rhs  )  [inline]

Copies another map.

Parameters:
rhs The map to be copied

Definition at line 711 of file nmap.hpp.

References begin(), NSkipList::clear(), end(), and insert().

Referenced by operator=().

NMap< K, V > & operator= ( const NMap< K, V > &  rhs  )  [inline]

Copies another map.

Parameters:
rhs The map to be copied
Returns:
A reference to the current object

Definition at line 742 of file nmap.hpp.

References copy().

bool operator!= ( const NMap< K, V > &  rhs  )  const [inline]

Tests whether a map differs from another.

Parameters:
rhs The map to be tested
Returns:
true if it differs or false otherwise

Definition at line 750 of file nmap.hpp.

References begin(), contains(), and end().

bool operator== ( const NMap< K, V > &  rhs  )  const [inline]

Tests whether a map equals another.

Parameters:
rhs The map to be tested
Returns:
true if it is equal or false otherwise

Definition at line 762 of file nmap.hpp.

References begin(), contains(), and end().

V operator[] ( const K &  keyname  )  [inline]

Gets the value of a given key.

Parameters:
keyname The value of the key
Returns:
The value or a default constructed value if not found

Definition at line 774 of file nmap.hpp.

References value().

const V & operator[] ( const K &  keyname  )  const [inline]

Gets the value of a given key.

Parameters:
keyname The value of the key
Returns:
The value or a default constructed value if not found

Definition at line 780 of file nmap.hpp.

References value().


The documentation for this class was generated from the following file:
Generated on Wed Mar 5 23:10:37 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4