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

tmap.cxx

Go to the documentation of this file.
00001 
00002 
00003 #include "cmt_std.h"
00004 #include "cmt_string.h"
00005 #include "cmt_vector.h"
00006 
00007 template  class cmt_pair
00008 {
00009 public:
00010   cmt_pair ()
00011   {
00012   }
00013 
00014   T1 first;
00015   T2 second;
00016 };
00017 
00018 template  class cmt_map
00019 {
00020 public:
00021   typedef cmt_pair  element_type;
00022 
00023   T2& operator [] (const T1& key)
00024   {
00025     for (int i = 0; i < elements.size (); i++)
00026       {
00027         element_type& e = elements[i];
00028 
00029         if (e.first == key)
00030           {
00031             return (e.second);
00032           }
00033       }
00034 
00035     element_type& e = elements.add ();
00036     
00037     e.first = key;
00038     return (e.second);
00039   }
00040 
00041 private:
00042   cmt_vector  elements;
00043 };
00044 
00045 int main ()
00046 {
00047   cmt_map  packages;
00048 
00049   cmt_string& s = packages[0];
00050 
00051   s = "CSet";
00052 
00053   return (0);
00054 }
00055 

Generated at Fri Apr 12 16:18:12 2002 for cmtgrapher by 1.2.3 written by , ??1997-2000