[Zion] Move Memory Mappings to a dedicated tree impl.
This commit is contained in:
parent
3e9923f227
commit
e668428d9d
7 changed files with 129 additions and 47 deletions
|
|
@ -107,6 +107,9 @@ void BinaryTree<K, V>::Delete(K key) {
|
|||
template <typename K, typename V>
|
||||
Optional<Ref<V>> BinaryTree<K, V>::Predecessor(K key) {
|
||||
auto current = FindOrInsertionParent(key);
|
||||
if (current.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// The case where the current is the insertion parent and
|
||||
// the predecessor is unique. If the key was going to be
|
||||
|
|
@ -139,6 +142,9 @@ Optional<Ref<V>> BinaryTree<K, V>::Predecessor(K key) {
|
|||
template <typename K, typename V>
|
||||
Optional<Ref<V>> BinaryTree<K, V>::Successor(K key) {
|
||||
auto current = FindOrInsertionParent(key);
|
||||
if (current.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// The case where the current is the insertion parent and
|
||||
// the predecessor is unique. If the key was going to be
|
||||
|
|
@ -171,6 +177,9 @@ Optional<Ref<V>> BinaryTree<K, V>::Successor(K key) {
|
|||
template <typename K, typename V>
|
||||
Optional<Ref<V>> BinaryTree<K, V>::Find(K key) {
|
||||
auto current = FindOrInsertionParent(key);
|
||||
if (current.empty()) {
|
||||
return {};
|
||||
}
|
||||
if (current->key == key) {
|
||||
return Optional<Ref<V>>(current->value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class Ref {
|
|||
Ref(Ref&& other) = default;
|
||||
|
||||
operator T&() const { return ref_; }
|
||||
T& get() const { return ref_; }
|
||||
|
||||
private:
|
||||
T& ref_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue