[Zion] Move Memory Mappings to a dedicated tree impl.

This commit is contained in:
Drew Galbraith 2023-11-19 18:45:13 -08:00
parent 3e9923f227
commit e668428d9d
7 changed files with 129 additions and 47 deletions

View file

@ -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);
}