00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef WM4TSTRINGHASHTABLE_H
00017 #define WM4TSTRINGHASHTABLE_H
00018
00019 #include "Wm4FoundationLIB.h"
00020
00021
00022
00023
00024
00025
00026 #include "Wm4System.h"
00027
00028 namespace Wm4
00029 {
00030
00031 template <class TVALUE>
00032 class TStringHashTable
00033 {
00034 public:
00035
00036 TStringHashTable (int iTableSize);
00037 ~TStringHashTable ();
00038
00039
00040 int GetQuantity () const;
00041
00042
00043 bool Insert (const std::string& rkKey, const TVALUE& rtValue);
00044
00045
00046 TVALUE* Find (const std::string& rkKey) const;
00047
00048
00049 bool Remove (const std::string& rkKey);
00050 void RemoveAll ();
00051
00052
00053 TVALUE* GetFirst (std::string* pkKey) const;
00054 TVALUE* GetNext (std::string* pkKey) const;
00055
00056 private:
00057 class HashItem
00058 {
00059 public:
00060 HashItem () : m_kKey("") { }
00061
00062 std::string m_kKey;
00063 TVALUE m_tValue;
00064 HashItem* m_pkNext;
00065 };
00066
00067
00068 int HashFunction (const std::string& rkKey) const;
00069
00070
00071 int m_iTableSize;
00072 int m_iQuantity;
00073 HashItem** m_apkTable;
00074
00075
00076 mutable int m_iIndex;
00077 mutable HashItem* m_pkItem;
00078 };
00079
00080 #include "Wm4TStringHashTable.inl"
00081
00082 }
00083
00084 #endif