|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Immutable path-copying treap set and map. More...
#include <algorithm>#include <concepts>#include <cstdint>#include <limits>#include <memory>#include <type_traits>#include <utility>#include <ah-errors.H>#include <ahFunction.H>#include <tpl_array.H>Go to the source code of this file.
Classes | |
| struct | Aleph::detail::PersistentTreapNodeOps< Node, Key, Compare > |
| class | Aleph::PersistentTreapSet< Key, Compare > |
| Immutable ordered set backed by a path-copying treap. More... | |
| struct | Aleph::PersistentTreapSet< Key, Compare >::Node |
| class | Aleph::PersistentTreapMap< Key, T, Compare > |
| Immutable ordered map backed by a path-copying treap. More... | |
| struct | Aleph::PersistentTreapMap< Key, T, Compare >::Node |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
| namespace | Aleph::detail |
Functions | |
| std::uint64_t | Aleph::detail::persistent_treap_priority (const std::uint64_t n) noexcept |
Immutable path-copying treap set and map.
A Treap is a randomized binary search tree that maintains both a BST property (for the keys) and a Min-Heap property (using randomly generated priorities). This guarantees balanced O(log n) tree depth with high probability.
"Persistence" in this context refers to immutability with history (structural sharing or path-copying). It does NOT mean disk storage. When a node is inserted, erased, or when the tree is split/joined, the existing tree is never mutated. Instead, a new root is returned. Only the nodes along the search path (and those affected by rotations) are copied. The rest of the subtrees remain completely untouched and are shared between the old and new versions using smart pointers (std::shared_ptr<const Node>).
This is unrelated to Aleph's file-backed B/B+ tree persistence: these containers are volatile in-memory values, not durable storage.
keys() and items() flatten a version in sorted order and cost O(n).Definition in file tpl_persistent_treap.H.