Polaris: KeyMap< S, T > Class Template Reference

KeyMap< S, T > Class Template Reference

#include <KeyMap.h>

Inheritance diagram for KeyMap< S, T >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

INLINE KeyMap ()
INLINE KeyMap (const KeyMap< S, T > &m)
virtual INLINE ~KeyMap ()
INLINE T & ins (S *key, T *data)
 Insert element with (key, data) into the map, and return a reference to '*data' (for purposes of programming convenience).
INLINE void del (S &del_key)
 delete element with key del_key
INLINE void print (ostream &out, char *sep1, char *sep2) const
 print map to out with sep1 between key and data and sep2 between each element of the map
INLINE KeyMap< S, T > & operator= (const KeyMap< S, T > &l)
 Copy operator completely copies the KeyMap.
INLINE Listablelistable_clone () const
 Needed for Listable class.
INLINE void print (ostream &o) const
 Needed for Listable class.

Protected Member Functions

virtual INLINE void _kill_key (BMKey &key)
 kill key

Detailed Description

template<class S, class T>
class KeyMap< S, T >

DESCRIPTION

KeyMap<key,data> owns(key,data), address(key)

A template for a map for owned keys of type S to owned objects of type T where:

    1.  'S' is a class with:
   
    a) <, == and << operators taking S& arguments.
    b) a copy constructor S(S &) to clone the
       input object or simple enough structure
       for the default copy constructor to work.
   
    2.  'T' is a class derived from Listable.

The map is implemented as a tree of pointers to whatever type is specified. Thus, all methods to insert elements into a map take a pointer to the key and data and do not allocate space. (i.e., the map aliases whatever is in the list). However, the map takes over ownership of the keys on insert and will delete both a map element and its associated key.

Definition at line 36 of file KeyMap.h.


Constructor & Destructor Documentation

template<class S, class T>
INLINE KeyMap< S, T >::KeyMap  ) 
 

< nothing to do

Definition at line 104 of file KeyMap.h.

template<class S, class T>
INLINE KeyMap< S, T >::KeyMap const KeyMap< S, T > &  m  ) 
 

< Invoke copy constructor

Definition at line 111 of file KeyMap.h.

template<class S, class T>
INLINE KeyMap< S, T >::~KeyMap  )  [virtual]
 

< Delete the information before the class disappears.

Definition at line 119 of file KeyMap.h.

References BaseMapRoot::clear().


Member Function Documentation

template<class S, class T>
INLINE void KeyMap< S, T >::_kill_key BMKey key  )  [protected, virtual]
 

kill key

Reimplemented from BaseMapRoot.

Definition at line 79 of file KeyMap.h.

template<class S, class T>
INLINE T & KeyMap< S, T >::ins S *  key,
T *  data
 

Insert element with (key, data) into the map, and return a reference to '*data' (for purposes of programming convenience).

If a node with an equivalent key already exists, delete the old one and replace it with the new one.

Definition at line 127 of file KeyMap.h.

References BMKey::_keyptr, BaseMapRoot::ins(), and BaseMapRoot::remove().

Referenced by main(), and KeyMap< S, T >::operator=().

template<class S, class T>
INLINE void KeyMap< S, T >::del S &  del_key  ) 
 

delete element with key del_key

Definition at line 146 of file KeyMap.h.

References BMKey::_keyptr, and BaseMapRoot::remove().

Referenced by main().

template<class S, class T>
INLINE void KeyMap< S, T >::print ostream &  out,
char *  sep1,
char *  sep2
const
 

print map to out with sep1 between key and data and sep2 between each element of the map

Reimplemented from ProtoMap< S, T >.

Definition at line 88 of file KeyMap.h.

References BMKey::_keyptr, and ProtoMap< S, T >::_print().

Referenced by KeyMap< S, T >::print().

template<class S, class T>
INLINE KeyMap< S, T > & KeyMap< S, T >::operator= const KeyMap< S, T > &  m  ) 
 

Copy operator completely copies the KeyMap.

< Clear out current map

< Copy all the items one by one

Definition at line 161 of file KeyMap.h.

References BaseMapRoot::clear(), and KeyMap< S, T >::ins().

template<class S, class T>
INLINE Listable * KeyMap< S, T >::listable_clone  )  const [virtual]
 

Needed for Listable class.

Implements Listable.

Definition at line 177 of file KeyMap.h.

template<class S, class T>
INLINE void KeyMap< S, T >::print ostream &  o  )  const [virtual]
 

Needed for Listable class.

It invokes a non-virtual member function to print a representation of the data structure at this level of the Collection hierarchy, and, since it is not a class member function, it must be explicitly instantiated before use.

Implements Listable.

Definition at line 184 of file KeyMap.h.

References KeyMap< S, T >::print().


The documentation for this class was generated from the following file:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:39 2005