My Project
|
00001 /* 00002 $Id: Map.hh 2249 2011-04-28 04:51:48Z jisuzuki $ 00003 */ 00004 00005 00006 #ifndef MAP_HH 00007 #define MAP_HH 00008 00009 #include <boost/serialization/serialization.hpp> 00010 #include <boost/serialization/nvp.hpp> 00011 00012 #include "Header.hh" 00014 00016 00038 template< class T > 00039 class Map 00040 { 00041 private: 00042 vector< string > *KeyVector; 00043 vector< T > *ValueVector; 00044 00045 friend class boost::serialization::access; 00049 template <class Archive> 00050 void serialize(Archive &ar, const unsigned int ver); 00051 00052 protected: 00053 Int4 _Check( string Key ) const; 00056 void _Add( string key, T value ); 00059 public: 00060 Map(); 00062 ~Map(); 00064 Map(const Map<T> &ob); 00066 Map<T> operator=( const Map<T> &ob ); 00067 00068 bool Empty() { return KeyVector->empty(); } 00071 UInt4 Size() const; 00073 UInt4 PutTableSize() const { return Size(); } 00076 UInt4 PutIndexNumber( string key ); 00079 void Add( string key, T value ); 00090 T Find( string key ); 00092 T Put( string key ){ return Find( key ); } 00096 T Put( UInt4 index ){ return ( *ValueVector )[index]; } 00097 string PutKey( UInt4 index ){ return (*KeyVector)[index]; } 00098 00099 00100 const T& operator[]( const string &key) const; 00102 T& operator[]( const string &key) ; 00106 void Clear(); 00109 void Remove( UInt4 IndexNumber ); 00112 void Remove( string key ); 00115 void Dump(); 00122 UInt4 Check( string Key ); 00129 friend class HeaderBase; 00130 }; 00132 #include "Map.cc" 00133 /* 00134 * 00135 * Map<T> does not have NXwrite and NXread, because HeaderBase writes and reads 00136 * them directly 00137 */ 00138 #endif