32 |
|
private: |
33 |
|
vector<T1> _keys; |
34 |
|
vector<T2> _data; |
35 |
< |
hash_map<T1, int, THashFcn, TEqualKey> _hashTable; |
35 |
> |
hash_map<T1, int, THashFcn, TEqualKey> _hashTable; |
36 |
|
int _num; |
37 |
|
|
38 |
+ |
void Clear(); |
39 |
|
public: |
40 |
|
TKeyList(); |
41 |
|
~TKeyList(); |
42 |
|
|
43 |
< |
int AddKey(T1 key, T2 data); |
43 |
> |
int AddKey(T1 key, T2 &data); |
44 |
|
int GetIndex(T1 key); |
45 |
|
|
46 |
|
const T2& GetDataByKey(string &str) const; |
47 |
|
const T2& GetDataByIndex(int index) const; |
48 |
|
const T1& GetKeyByIndex(int index) const; |
49 |
|
|
50 |
< |
void SetDataByIndex(int index, T2 data); |
51 |
< |
void SetDataByKey(T1 key, T2 data); |
52 |
< |
void ChangeKey(int index, T1 key); |
50 |
> |
void SetDataByIndex(int index, T2 &data); |
51 |
> |
void SetDataByKey(T1 key, T2 &data); |
52 |
> |
void ChangeKey(int index, T1 newKey); |
53 |
|
void ChangeKey(T1 oldKey, T1 newKey); |
54 |
|
|
55 |
|
}; |
55 |
– |
|
56 |
– |
struct TEqstr |
57 |
– |
{ |
58 |
– |
bool operator()(const string *s1, string *s2) const |
59 |
– |
{ |
60 |
– |
return *s1 == *s2; |
61 |
– |
} |
62 |
– |
}; |
56 |
|
|
64 |
– |
|
57 |
|
typedef TKeyList<string, int, hash<string>, equal_to<string> > TNameList; |
58 |
|
|
59 |
|
|