forked from OctaForge/libostd
simplify and fix multimap/multiset emplace
parent
770f5ea0f2
commit
9729ce1bbc
|
@ -520,20 +520,10 @@ public:
|
||||||
* gotta make sure that equal keys always come after
|
* gotta make sure that equal keys always come after
|
||||||
* each other (this is then used by other APIs)
|
* each other (this is then used by other APIs)
|
||||||
*/
|
*/
|
||||||
Size h = 0;
|
Size h = bucket(B::get_key(elem));
|
||||||
Chain *found = find(B::get_key(elem), h);
|
Chain *ch = insert(h);
|
||||||
if (!found) {
|
|
||||||
Chain *ch = insert(h);
|
|
||||||
B::swap_elem(ch->value, elem);
|
|
||||||
return make_pair(Range(ch), true);
|
|
||||||
}
|
|
||||||
Chain *ch = request_node();
|
|
||||||
B::swap_elem(ch->value, elem);
|
B::swap_elem(ch->value, elem);
|
||||||
Chain *next = found->next;
|
return make_pair(Range(ch), true);
|
||||||
found->next = ch;
|
|
||||||
ch->prev = found;
|
|
||||||
ch->next = next;
|
|
||||||
if (next) next->prev = ch;
|
|
||||||
}
|
}
|
||||||
Size h = bucket(B::get_key(elem));
|
Size h = bucket(B::get_key(elem));
|
||||||
Chain *found = nullptr;
|
Chain *found = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue