Changeset View
Changeset View
Standalone View
Standalone View
src/radix.h
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | bool insert(const K &key, T *value) { | ||||
const K &leafKey = e.getLeaf()->getId(); | const K &leafKey = e.getLeaf()->getId(); | ||||
if (key == leafKey) { | if (key == leafKey) { | ||||
return false; | return false; | ||||
} | } | ||||
// There is an element there, but it isn't a subtree. We need to | // There is an element there, but it isn't a subtree. We need to | ||||
// convert it into a subtree and resume insertion into that subtree. | // convert it into a subtree and resume insertion into that subtree. | ||||
std::unique_ptr<RadixNode> newChild = | std::unique_ptr<RadixNode> newChild = | ||||
MakeUnique<RadixNode>(level, leafKey, e); | std::make_unique<RadixNode>(level, leafKey, e); | ||||
if (eptr->compare_exchange_strong(e, | if (eptr->compare_exchange_strong(e, | ||||
RadixElement(newChild.get()))) { | RadixElement(newChild.get()))) { | ||||
// We have a subtree, resume normal operations from there. | // We have a subtree, resume normal operations from there. | ||||
newChild.release(); | newChild.release(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |