Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VALUE& operator[](const KEY& key) {
- size_t index = _hash(key) % _table.size();
- LIST& list = _table[index];
- for (auto iter = list.begin(); iter != list.end(); ++iter) {
- if (iter->first == key) {
- return iter->second;
- }
- }
- _size++;
- if (double(_size) / _table.size() > max_coef) {
- this->rehash(_table.size() * size_t(max_coef));
- LIST& new_list = _table[_hash(key) % _table.size()];
- new_list.push_back(PAIR(key, VALUE()));
- return new_list.back().second;
- }
- list.push_back(PAIR(key, VALUE()));
- return list.back().second;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement