better hashtable erase

master
Daniel Kolesa 2015-07-21 02:11:53 +01:00
parent 71f5df79ce
commit 852ae9ea37
1 changed files with 21 additions and 20 deletions

View File

@ -554,12 +554,13 @@ public:
} }
Size erase(const K &key) { Size erase(const K &key) {
if (!p_len) return 0; Size h = 0;
Size olen = p_len; Chain *c = find(key, h);
Size h = bucket(key); if (!c) return 0;
Chain **cp = p_data.first(); Chain **cp = p_data.first();
for (Chain *c = cp[h], *e = cp[h + 1]; c != e; c = c->next) Size olen = p_len;
if (get_eq()(key, B::get_key(c->value))) { for (Chain *e = cp[h + 1]; c != e; c = c->next) {
if (!get_eq()(key, B::get_key(c->value))) break;
--p_len; --p_len;
Size hh = h; Size hh = h;
Chain *next = c->next; Chain *next = c->next;