c12p713.txt

来自「Data Abstraction & Problem Solving with 」· 文本 代码 · 共 44 行

TXT
44
字号
// ****************************************************// Implementation file HashMap.cpp // ****************************************************template <class Key, class T, class Hash>HashMap<Key, T, Hash>::HashMap(int maxBuckets){   hash = Hash();   resize(maxBuckets+1);} // end constructortemplate <class Key, class T, class Hash>T& HashMap<Key, T, Hash>::operator[](Key& key){   return at(hash(key))[key];} // end operator[]template <class Key, class T, class Hash>map<Key, T>::const_iterator HashMap<Key, T, Hash>::findItem                                             (const Key& key){   map<Key, T>::const_iterator it;   int index = hash(key);   it = at(index).find(key);	   return it;} // end findItemtemplate <class Key, class T, class Hash>void HashMap<Key, T, Hash>::insert (const Key& key,                                    const T& item){    int index = hash(key);    at(index).insert(make_pair(key, item));} // end inserttemplate <class Key, class T, class Hash>int HashMap<Key, T, Hash>::erase(const Key& key){    int index = hash(key);    return at(index).erase(key); } // end erase// End of implementation file

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?