Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

MapC< Key, Value > Class Template Reference

#include <mapc.h>

Inheritance diagram for MapC< Key, Value >:

Inheritance graph
[legend]
Collaboration diagram for MapC< Key, Value >:

Collaboration graph
[legend]
List of all members.

Public Methods

 MapC ()
 MapC (const MapC< Key, Value > &a)
void SetBlanc (const Value &t)
void set (Key k, const Value &v)
const Value & get (const Key &k) const
void RemoveKey (const Key &key)
void Empty ()
const MapC< Key, Value > & operator= (const MapC< Key, Value > &a)
long size () const

Protected Methods

long lookupIndex (const Key &k) const

Protected Attributes

ArrayC< Key > m_keys
ArrayC< Value > m_values
Value m_blanc
ArrayC< long > m_freeIndexes
ArrayC< short > m_occupied

template<class Key, class Value>
class MapC< Key, Value >


Constructor & Destructor Documentation

template<class Key, class Value>
MapC< Key, Value >::MapC   [inline]
 

Definition at line 42 of file mapc.h.

00042 {}

template<class Key, class Value>
MapC< Key, Value >::MapC const MapC< Key, Value > &    a [inline]
 

Definition at line 43 of file mapc.h.

00043                                 {
00044     m_keys = a.m_keys;
00045     m_values = a.m_values;
00046     m_occupied = a.m_occupied;
00047     m_freeIndexes = a.m_freeIndexes;
00048     m_blanc = a.m_blanc;
00049   }


Member Function Documentation

template<class Key, class Value>
void MapC< Key, Value >::Empty   [inline]
 

Definition at line 84 of file mapc.h.

00084               {
00085     m_values.Empty();
00086     m_keys.Empty();
00087   }

template<class Key, class Value>
const Value& MapC< Key, Value >::get const Key &    k const [inline]
 

Definition at line 71 of file mapc.h.

00071                                              {
00072     long ix = lookupIndex(k);
00073     if(ix<0){return m_blanc;}
00074     return m_values.get(ix);
00075   }

template<class Key, class Value>
long MapC< Key, Value >::lookupIndex const Key &    k const [inline, protected]
 

Definition at line 102 of file mapc.h.

Referenced by MapC< FontType, Win32GL3DFont * >::get(), MapC< FontType, Win32GL3DFont * >::RemoveKey(), and MapC< FontType, Win32GL3DFont * >::set().

00102                                       {
00103     long i;
00104     for(i=0;i<m_keys.size();i++){
00105       if(m_occupied.get(i) && m_keys.get(i)==k){
00106         return i;
00107       }
00108     }
00109     return -1;
00110   }

template<class Key, class Value>
const MapC<Key,Value>& MapC< Key, Value >::operator= const MapC< Key, Value > &    a [inline]
 

Definition at line 89 of file mapc.h.

00089                                                               {
00090     m_keys = a.m_keys;
00091     m_values = a.m_values;
00092     m_occupied = a.m_occupied;
00093     m_freeIndexes = a.m_freeIndexes;
00094     m_blanc = a.m_blanc;
00095     return *this;
00096   }

template<class Key, class Value>
void MapC< Key, Value >::RemoveKey const Key &    key [inline]
 

Definition at line 77 of file mapc.h.

00077                                 {
00078     long ix = lookupIndex(i);
00079     if(ix<0){return;}
00080     m_occupied[ix]=0;
00081     m_freeIndexes.push_back(ix);
00082   }

template<class Key, class Value>
void MapC< Key, Value >::set Key    k,
const Value &    v
[inline]
 

Definition at line 53 of file mapc.h.

00053                                  {
00054     long ix = lookupIndex(k);
00055     if(ix<=0){
00056       if(m_freeIndexes.size()==0){
00057         m_values.push_back(v);
00058         m_keys.push_back(k);
00059         m_occupied.push_back(1);
00060       }else{
00061         m_freeIndexes.pop_back(ix);
00062         m_values[ix]=v;
00063         m_keys[ix]=k;
00064         m_occupied[ix]=1;
00065       }
00066     }else{
00067       m_values[ix]=v;
00068     }
00069   }

template<class Key, class Value>
void MapC< Key, Value >::SetBlanc const Value &    t [inline]
 

Definition at line 51 of file mapc.h.

00051 {m_blanc = t;}

template<class Key, class Value>
long MapC< Key, Value >::size   const [inline]
 

Definition at line 98 of file mapc.h.

00098 {return m_keys.size();}


Member Data Documentation

template<class Key, class Value>
Value MapC< Key, Value >::m_blanc [protected]
 

Definition at line 115 of file mapc.h.

Referenced by MapC< FontType, Win32GL3DFont * >::get(), MapC< FontType, Win32GL3DFont * >::MapC(), MapC< FontType, Win32GL3DFont * >::operator=(), and MapC< FontType, Win32GL3DFont * >::SetBlanc().

template<class Key, class Value>
ArrayC<long> MapC< Key, Value >::m_freeIndexes [protected]
 

Definition at line 117 of file mapc.h.

Referenced by MapC< FontType, Win32GL3DFont * >::MapC(), MapC< FontType, Win32GL3DFont * >::operator=(), MapC< FontType, Win32GL3DFont * >::RemoveKey(), and MapC< FontType, Win32GL3DFont * >::set().

template<class Key, class Value>
ArrayC<Key> MapC< Key, Value >::m_keys [protected]
 

Definition at line 113 of file mapc.h.

Referenced by MapC< FontType, Win32GL3DFont * >::Empty(), MapC< FontType, Win32GL3DFont * >::lookupIndex(), MapC< FontType, Win32GL3DFont * >::MapC(), MapC< FontType, Win32GL3DFont * >::operator=(), MapC< FontType, Win32GL3DFont * >::set(), and MapC< FontType, Win32GL3DFont * >::size().

template<class Key, class Value>
ArrayC<short> MapC< Key, Value >::m_occupied [protected]
 

Definition at line 118 of file mapc.h.

Referenced by MapC< FontType, Win32GL3DFont * >::lookupIndex(), MapC< FontType, Win32GL3DFont * >::MapC(), MapC< FontType, Win32GL3DFont * >::operator=(), MapC< FontType, Win32GL3DFont * >::RemoveKey(), and MapC< FontType, Win32GL3DFont * >::set().

template<class Key, class Value>
ArrayC<Value> MapC< Key, Value >::m_values [protected]
 

Definition at line 114 of file mapc.h.

Referenced by MapC< FontType, Win32GL3DFont * >::Empty(), MapC< FontType, Win32GL3DFont * >::get(), MapC< FontType, Win32GL3DFont * >::MapC(), MapC< FontType, Win32GL3DFont * >::operator=(), and MapC< FontType, Win32GL3DFont * >::set().


The documentation for this class was generated from the following file:
Generated on Tue Jul 29 14:30:51 2003 for Open ActiveWrl by doxygen1.3-rc2