Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmt_map< K, T > Class Template Reference

Public interface for maps. More...

#include <cmt_map.h>

List of all members.

Public Member Functions

 cmt_map ()
 Constructor.

 ~cmt_map ()
 Destructor.

void clear ()
 clear: erase everything from this map

void add (const K &key, T &t)
 Add an entry.

void add (const K &key, T *t)
bool has (const K &key) const
 Finds whether there is a node holding that key.

T * find (const K &key) const
 Finds the value associated with that key.

const cmt_node< K, T > * find_node (const K &key) const
 Finds the node containing the value associated with that key.


Private Attributes

cmt_node< K, T > * m_top


Detailed Description

template<class K, class T>
class cmt_map< K, T >

Public interface for maps.

It is implemented by one top cmt_node.

At creation the map is empty.

Definition at line 333 of file cmt_map.h.


Constructor & Destructor Documentation

template<class K, class T>
cmt_map< K, T >::cmt_map  )  [inline]
 

Constructor.

Definition at line 340 of file cmt_map.h.

00340              : m_top (0)
00341   {
00342   }

template<class K, class T>
cmt_map< K, T >::~cmt_map  )  [inline]
 

Destructor.

Definition at line 347 of file cmt_map.h.

00348   {
00349     clear ();
00350   }


Member Function Documentation

template<class K, class T>
void cmt_map< K, T >::add const K &  key,
T *  t
[inline]
 

Definition at line 381 of file cmt_map.h.

00382   {
00383     if (m_top == 0)
00384       {
00385         m_top = new cmt_node<K, T> (key, *t);
00386       }
00387     else
00388       {
00389         m_top->add (key, *t);
00390       }
00391   }

template<class K, class T>
void cmt_map< K, T >::add const K &  key,
T &  t
[inline]
 

Add an entry.

Existing entries with the same key will be overridden

Definition at line 369 of file cmt_map.h.

Referenced by Package::add(), Tag::add(), PatternList::add(), add_request(), CommandHelp::CommandHelp(), Symbol::create(), and Use::get_all_clients().

00370   {
00371     if (m_top == 0)
00372       {
00373         m_top = new cmt_node<K, T> (key, t);
00374       }
00375     else
00376       {
00377         m_top->add (key, t);
00378       }
00379   }

template<class K, class T>
void cmt_map< K, T >::clear  )  [inline]
 

clear: erase everything from this map

Definition at line 355 of file cmt_map.h.

Referenced by Package::clear_all(), Tag::clear_all(), Symbol::clear_all(), PatternList::clear_all(), and cmt_map< cmt_string, Package >::~cmt_map().

00356   {
00357     if (m_top != 0)
00358       {
00359         delete m_top;
00360         m_top = 0;
00361       }
00362   }

template<class K, class T>
T* cmt_map< K, T >::find const K &  key  )  const [inline]
 

Finds the value associated with that key.

Returns 0 if not found

Definition at line 412 of file cmt_map.h.

Referenced by Package::find(), Tag::find(), Symbol::find(), and PatternList::find().

00413   {
00414     if (m_top != 0)
00415       {
00416         return (m_top->find (key));
00417       }
00418     else
00419       {
00420         return (0);
00421       }
00422   }

template<class K, class T>
const cmt_node<K, T>* cmt_map< K, T >::find_node const K &  key  )  const [inline]
 

Finds the node containing the value associated with that key.

Returns 0 if not found

Definition at line 428 of file cmt_map.h.

00429   {
00430     if (m_top == 0) return (0);
00431 
00432     return (m_top->find_node (key));
00433   }

template<class K, class T>
bool cmt_map< K, T >::has const K &  key  )  const [inline]
 

Finds whether there is a node holding that key.

Definition at line 396 of file cmt_map.h.

Referenced by add_request(), and Use::get_all_clients().

00397   {
00398     if (m_top != 0)
00399       {
00400         return (m_top->has (key));
00401       }
00402     else
00403       {
00404         return (false);
00405       }
00406   }


Member Data Documentation

template<class K, class T>
cmt_node<K, T>* cmt_map< K, T >::m_top [private]
 

Definition at line 436 of file cmt_map.h.


The documentation for this class was generated from the following file:
Generated on Mon May 2 10:25:29 2005 for CMT by doxygen 1.3.5