| | |
| | | Hashelement OverFlow;
|
| | | public:
|
| | |
|
| | | Hash::~Hash()
|
| | | ~Hash()
|
| | | {
|
| | | }
|
| | |
|
| | | Hash::Hash(void)
|
| | | Hash(void)
|
| | | {
|
| | | TotalKey=0;
|
| | | OverFlow = _T("OverFlow");
|
| | | };
|
| | | Hash::Hash(CString thisName)
|
| | | Hash(CString thisName)
|
| | | {
|
| | | TotalKey=0;
|
| | | this->Name=thisName;
|
| | |
| | | }
|
| | | TotalKey=0;
|
| | | }
|
| | | bool Exist(CString s)
|
| | | {
|
| | | int left = 0;
|
| | | int right = TotalKey - 1;
|
| | | int mid;
|
| | |
|
| | | Hashelement & Hash::operator [] (const char * str)
|
| | | int index = -1;
|
| | | while (left <= right)
|
| | | {
|
| | | mid = (left + right) / 2;
|
| | | int r = elements[mid].Key->CompareNoCase(s);
|
| | | if (r < 0)
|
| | | {//key在右边
|
| | | left = mid + 1;
|
| | | }
|
| | | else if (r > 0)
|
| | | {//key在左边
|
| | | right = mid - 1;
|
| | | }
|
| | | else
|
| | | {
|
| | | index = mid;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (index == -1) return false;
|
| | | else return true;
|
| | | }
|
| | | Hashelement & operator [] (const char * str)
|
| | | {
|
| | | CString s1(str);
|
| | | return this->operator [] (s1);
|
| | | };
|
| | | Hashelement & Hash::operator [] (CString s)
|
| | | Hashelement & operator [] (CString s)
|
| | | {
|
| | | int left = 0;
|
| | | int right = TotalKey - 1;
|
| | |
| | |
|
| | | return elements[index];
|
| | | };
|
| | | Hashelement & Hash::operator [] (int k)
|
| | | Hashelement & operator [] (int k)
|
| | | {
|
| | | return elements[k];
|
| | | };
|
| | |
| | | }
|
| | | return nCount;
|
| | | }
|
| | | int Hash::SaveToFile(CString FilePathName,CString Section)
|
| | | int SaveToFile(CString FilePathName,CString Section)
|
| | | {
|
| | | int i;
|
| | | CString Key,Value;
|
| | |
| | | return 1;
|
| | | };
|
| | |
|
| | | int Hash::LoadFromFile(CString FilePathName,CString Section)
|
| | | int LoadFromFile(CString FilePathName,CString Section)
|
| | | {
|
| | | CString Key;
|
| | | CString value,value1,value2;
|
| | |
| | | for (int i=0; i<h2.TotalKey; ++i)
|
| | | {
|
| | | CString key = *(h2.elements[i].Key);
|
| | | CString value1 = h1[key];
|
| | | CString value1 = *(h1[key].Value);
|
| | | CString value2 = *(h2.elements[i].Value);
|
| | | if (value1.GetLength()>256 || value2.GetLength()>256)
|
| | | {
|