|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Generic B+ Tree with configurable minimum degree. More...
#include <tpl_bplus_tree.H>
Classes | |
| class | Iterator |
| Lazy iterator over ordered leaf keys. More... | |
Public Types | |
| using | key_type = Key |
| Stored key type. | |
Public Member Functions | |
| Gen_BPlus_Tree (const Compare &cmp=Compare()) | |
| Construct an empty B+ Tree. | |
| template<std::input_iterator It> | |
| Gen_BPlus_Tree (It first, It last, const Compare &cmp=Compare()) | |
| Construct a B+ Tree from an iterator range. | |
| Gen_BPlus_Tree (std::initializer_list< Key > init, const Compare &cmp=Compare()) | |
| Construct a B+ Tree from an initializer list. | |
| Gen_BPlus_Tree (const Gen_BPlus_Tree &other) | |
| Copy constructor performing a deep copy. | |
| Gen_BPlus_Tree (Gen_BPlus_Tree &&other) noexcept(std::is_nothrow_copy_constructible_v< Compare >) | |
| Move constructor: take the keys of another tree, which is left empty. | |
| Gen_BPlus_Tree & | operator= (const Gen_BPlus_Tree &other) |
| Copy assignment. | |
| Gen_BPlus_Tree & | operator= (Gen_BPlus_Tree &&other) noexcept(noexcept(swap(other))) |
| Move assignment: exchange this tree with another, which is left with the previous keys of this one. | |
| void | swap (Gen_BPlus_Tree &other) noexcept(std::is_nothrow_swappable_v< Compare >) |
| Exchange the keys and the comparators of this tree and another. | |
| const Compare & | key_comp () const noexcept |
| Return the comparison object (read-only). | |
| const Compare & | get_compare () const noexcept |
| Return the comparison object (read-only). | |
| bool | empty () const noexcept |
| Return whether the tree has no keys. | |
| bool | is_empty () const noexcept |
| Synonym for empty() in traditional Aleph style. | |
| size_t | size () const noexcept |
| Return the number of stored keys. | |
| size_t | height () const noexcept |
| Return the current tree height. | |
| void | clear () noexcept |
| Remove every key from the tree. | |
| bool | contains (const Key &key) const |
| Return whether a key is present. | |
| bool | search (const Key &key) const |
| Synonym for contains(). | |
| bool | insert (const Key &key) |
| Insert a key if it is not already present. | |
| bool | insert (Key &&key) |
| Insert a key by move if it is not already present. | |
| bool | remove (const Key &key) |
| Remove a key if present. | |
| std::optional< Key > | min_key () const |
| Return the minimum key, if any. | |
| std::optional< Key > | max_key () const |
| Return the maximum key, if any. | |
| std::optional< Key > | lower_bound (const Key &key) const |
Return the first key not less than key. | |
| std::optional< Key > | upper_bound (const Key &key) const |
Return the first key strictly greater than key. | |
| Iterator | get_it () const noexcept |
| Return a lazy iterator over the full key order. | |
| Iterator | get_range_it (const Key &first, const Key &last) const |
| Return a lazy iterator over an inclusive key range. | |
| Array< Key > | range (const Key &first, const Key &last) const |
Collect all keys in the inclusive range [first, last]. | |
| Array< Key > | keys () const |
| Materialize the tree contents in sorted order. | |
| bool | verify () const |
| Verify structural B+ Tree invariants. | |
Private Types | |
| using | Node = detail::BPlusTreeNode< Key > |
Private Member Functions | |
| size_t | lower_bound_index (const Array< Key > &keys, const Key &key) const |
| size_t | upper_bound_index (const Array< Key > &keys, const Key &key) const |
| size_t | child_index (const Node *node, const Key &key) const |
| bool | equals (const Key &lhs, const Key &rhs) const |
| bool | strictly_sorted (const Array< Key > &keys) const |
| template<std::input_iterator It> | |
| void | insert_range (It first, It last) |
| const Node * | leftmost_leaf (const Node *node) const noexcept |
| const Node * | rightmost_leaf (const Node *node) const noexcept |
| const Key * | subtree_min_ptr (const Node *node) const noexcept |
| const Key * | subtree_max_ptr (const Node *node) const noexcept |
| const Key & | subtree_min (const Node *node) const |
| size_t | height_of (const Node *node) const noexcept |
| void | rebuild_separators (Node *node) const |
| std::unique_ptr< Node > | clone_node (const Node *node, Node *&prev_leaf) const |
| const Node * | find_leaf (const Key &key) const |
| bool | contains_in (const Node *node, const Key &key) const |
| void | split_child (Node *parent, const size_t idx) |
| void | insert_nonfull (Node *node, const Key &key) |
| void | borrow_from_prev (Node *parent, const size_t idx) |
| void | borrow_from_next (Node *parent, const size_t idx) |
| void | merge_children (Node *parent, const size_t left_idx) |
| void | fix_underflow (Node *parent, const size_t idx) |
| bool | remove_from (Node *node, const Key &key) |
| bool | verify_leaf_chain () const |
| bool | verify_node (const Node *node, const std::optional< Key > &min_key, const std::optional< Key > &max_key, const size_t depth, size_t &leaf_depth, size_t &counted) const |
Static Private Member Functions | |
| template<typename T , typename U > | |
| static void | insert_at (Array< T > &array, const size_t idx, U &&value) |
| template<typename T > | |
| static T | erase_at (Array< T > &array, const size_t idx) |
| template<typename T > | |
| static void | truncate (Array< T > &array, const size_t new_size) |
| template<typename T > | |
| static void | append_copy_range (Array< T > &dst, const Array< T > &src, const size_t from) |
| template<typename T > | |
| static void | append_move_range (Array< T > &dst, Array< T > &src, const size_t from) |
Private Attributes | |
| std::unique_ptr< Node > | root_ |
| size_t | size_ = 0 |
| Compare | cmp_ |
Static Private Attributes | |
| static constexpr size_t | MaxKeys = 2 * MinDegree - 1 |
| static constexpr size_t | MinKeys = MinDegree - 1 |
Generic B+ Tree with configurable minimum degree.
Gen_BPlus_Tree models an ordered set of unique keys. All payload keys are stored in leaves, while internal nodes keep only separator keys. This organization is specially convenient for page-oriented indexes, database style range scans, and any workload where ordered iteration matters as much as point lookups.
| Key | Key type stored in the tree. |
| Compare | Strict weak ordering used to sort keys. |
| MinDegree | Minimum degree t of the B+ Tree. Valid values are t >= 2. |
k is the number of reported keysfalse. Array<Key> results. Mutating operations preserve leaf links and search invariants if Compare and Key operations do not throw in the middle of internal node updates; allocation failures propagate as std::bad_alloc. Definition at line 135 of file tpl_bplus_tree.H.
| using Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::key_type = Key |
Stored key type.
Definition at line 637 of file tpl_bplus_tree.H.
|
private |
Definition at line 140 of file tpl_bplus_tree.H.
|
inlineexplicit |
Construct an empty B+ Tree.
| cmp | Comparison functor used to sort keys. |
| Nothing. |
Definition at line 769 of file tpl_bplus_tree.H.
|
inline |
Construct a B+ Tree from an iterator range.
| first | First element to insert. |
| last | One-past-the-end iterator. |
| cmp | Comparison functor used to sort keys. |
| std::bad_alloc | if internal storage allocation fails. |
Definition at line 777 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_range().
|
inline |
Construct a B+ Tree from an initializer list.
| init | Keys to insert. |
| cmp | Comparison functor used to sort keys. |
| std::bad_alloc | if internal storage allocation fails. |
Definition at line 787 of file tpl_bplus_tree.H.
|
inline |
Copy constructor performing a deep copy.
| other | Tree to copy. |
| std::bad_alloc | if cloning internal nodes fails. |
Definition at line 795 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::clone_node(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_.
|
inlinenoexcept |
Move constructor: take the keys of another tree, which is left empty.
The implicit move took the root but copied the size: the moved-from tree reported keys that it no longer had, and failed verify(). The comparator is copied, since the tree left empty still uses it.
| other | Tree to move from. |
| Whatever | copying the comparator throws. |
Definition at line 811 of file tpl_bplus_tree.H.
|
inlinestaticprivate |
Definition at line 221 of file tpl_bplus_tree.H.
References Aleph::Array< T >::append(), Aleph::Array< T >::reserve(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::merge_children(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child().
|
inlinestaticprivate |
Definition at line 228 of file tpl_bplus_tree.H.
References Aleph::Array< T >::append(), Aleph::Array< T >::reserve(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::merge_children().
|
inlineprivate |
Definition at line 446 of file tpl_bplus_tree.H.
References Aleph::Array< T >::append(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::erase_at(), Aleph::Array< T >::get_first(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::fix_underflow().
|
inlineprivate |
Definition at line 425 of file tpl_bplus_tree.H.
References Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Array< T >::get_last(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_at(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators(), and Aleph::Array< T >::remove_last().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::fix_underflow().
|
inlineprivate |
Definition at line 165 of file tpl_bplus_tree.H.
References Aleph::detail::BPlusTreeNode< Key >::keys, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound_index().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::find_leaf(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from().
|
inlinenoexcept |
Remove every key from the tree.
| Nothing. |
Definition at line 921 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
|
inlineprivate |
Definition at line 298 of file tpl_bplus_tree.H.
References Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::clone_node(), Aleph::copy(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::detail::BPlusTreeNode< Key >::next, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Gen_BPlus_Tree(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::clone_node().
|
inline |
Return whether a key is present.
| key | Key to search. |
true if the key exists, otherwise false. | Any | exception propagated by Compare. |
Definition at line 932 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains_in(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::search().
|
inlineprivate |
Definition at line 329 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::equals(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::find_leaf(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains().
|
inlinenoexcept |
Return whether the tree has no keys.
true if empty, otherwise false. | Nothing. |
Definition at line 886 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::is_empty().
|
inlineprivate |
Definition at line 170 of file tpl_bplus_tree.H.
References Aleph::detail::bplus_equiv(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains_in(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound_index(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlinestaticprivate |
Definition at line 203 of file tpl_bplus_tree.H.
References Aleph::close_gap(), Aleph::Array< T >::remove_last(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::borrow_from_next(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::merge_children(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from().
|
inlineprivate |
Definition at line 321 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::child_index(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::detail::BPlusTreeNode< Key >::leaf, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::Iterator(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains_in(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound().
|
inlineprivate |
Definition at line 487 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::borrow_from_next(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::borrow_from_prev(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::merge_children(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MinKeys, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from().
|
inlinenoexcept |
Return the comparison object (read-only).
| Nothing. |
Definition at line 877 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::key_comp().
|
inlinenoexcept |
Return a lazy iterator over the full key order.
| Nothing. |
Definition at line 1100 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys().
|
inline |
Return a lazy iterator over an inclusive key range.
| first | Lower endpoint, inclusive. |
| last | Upper endpoint, inclusive. |
| std::invalid_argument | if last < first according to Compare. |
| Any | exception propagated by Compare. |
Definition at line 1112 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::range().
|
inlinenoexcept |
Return the current tree height.
0 for an empty tree, otherwise the number of node levels. | Nothing. |
Definition at line 913 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::height_of(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::height_of().
|
inlineprivatenoexcept |
Definition at line 274 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::height().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::height().
|
inline |
Insert a key if it is not already present.
| key | Key to insert. |
true if insertion happened, false if it was duplicate. | std::bad_alloc | if node growth fails. |
| Any | exception propagated by Compare or Key copy/move operations. |
Definition at line 954 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MaxKeys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_range().
|
inline |
Insert a key by move if it is not already present.
| key | Key to insert. |
true if insertion happened, false if it was duplicate. | std::bad_alloc | if node growth fails. |
| Any | exception propagated by Compare or Key move/copy operations. |
Definition at line 996 of file tpl_bplus_tree.H.
References Aleph::copy(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert().
|
inlinestaticprivate |
Definition at line 189 of file tpl_bplus_tree.H.
References Aleph::Array< T >::append(), Aleph::open_gap(), Aleph::Array< T >::putn(), Aleph::Array< T >::size(), and value.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::borrow_from_prev(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child().
|
inlineprivate |
Definition at line 400 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::child_index(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::copy(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_at(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MaxKeys, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull().
|
inlineprivate |
Definition at line 183 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Gen_BPlus_Tree().
|
inlinenoexcept |
Synonym for empty() in traditional Aleph style.
true if empty, otherwise false. | Nothing. |
Definition at line 895 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::empty().
|
inlinenoexcept |
Return the comparison object (read-only).
| Nothing. |
Definition at line 867 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::get_compare().
|
inline |
Materialize the tree contents in sorted order.
| std::bad_alloc | if the result array cannot grow. |
| Any | exception propagated by Key copy construction. |
Definition at line 1140 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::get_it(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::has_curr(), out, Aleph::Array< T >::reserve(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::strictly_sorted(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound_index(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivatenoexcept |
Definition at line 235 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::detail::BPlusTreeNode< Key >::children, and Aleph::detail::BPlusTreeNode< Key >::leaf.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min_ptr(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_leaf_chain().
|
inline |
Return the first key not less than key.
| key | Probe key. |
std::nullopt if none exists. | Any | exception propagated by Compare or Key copy construction. |
Definition at line 1055 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::find_leaf(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::detail::BPlusTreeNode< Key >::next, and Aleph::Array< T >::size().
|
inlineprivate |
Definition at line 149 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::Iterator(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains_in(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from().
|
inline |
Return the maximum key, if any.
std::nullopt if empty. | Any | exception propagated by Key copy construction. |
Definition at line 1042 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_max_ptr().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivate |
Definition at line 467 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::append_copy_range(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::append_move_range(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::erase_at(), GenericItems< Container, T >::keys(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::detail::BPlusTreeNode< Key >::next, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::fix_underflow().
|
inline |
Return the minimum key, if any.
std::nullopt if empty. | Any | exception propagated by Key copy construction. |
Definition at line 1030 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min_ptr().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inline |
Copy assignment.
| other | Tree to copy from. |
*this. Definition at line 819 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
|
inlinenoexcept |
Move assignment: exchange this tree with another, which is left with the previous keys of this one.
| other | Tree to move from. |
*this. Definition at line 838 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::swap().
|
inline |
Collect all keys in the inclusive range [first, last].
| first | Lower endpoint, inclusive. |
| last | Upper endpoint, inclusive. |
| std::invalid_argument | if last < first according to Compare. |
| std::bad_alloc | if the result array cannot grow. |
| Any | exception propagated by Compare or Key copy construction. |
Definition at line 1125 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::get_range_it(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::has_curr(), out, and Aleph::Array< T >::reserve().
|
inlineprivate |
Definition at line 287 of file tpl_bplus_tree.H.
References Aleph::Array< T >::append(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Array< T >::empty(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Array< T >::reserve(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::borrow_from_next(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::borrow_from_prev(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::clone_node(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::fix_underflow(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::merge_children(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from().
|
inline |
Remove a key if present.
| key | Key to erase. |
true if the key was removed, otherwise false. | Any | exception propagated by Compare or Key assignments. |
Definition at line 1007 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
|
inlineprivate |
Definition at line 513 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::child_index(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::equals(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::erase_at(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::fix_underflow(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove_from().
|
inlineprivatenoexcept |
Definition at line 243 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::detail::BPlusTreeNode< Key >::children, and Aleph::detail::BPlusTreeNode< Key >::leaf.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_max_ptr().
|
inline |
Synonym for contains().
| key | Key to search. |
true if the key exists, otherwise false. | Any | exception propagated by Compare. |
Definition at line 942 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains().
|
inlinenoexcept |
Return the number of stored keys.
| Nothing. |
Definition at line 904 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
|
inlineprivate |
Definition at line 349 of file tpl_bplus_tree.H.
References Aleph::Array< T >::append(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::append_copy_range(), Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_at(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MaxKeys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MinKeys, Aleph::detail::BPlusTreeNode< Key >::next, Aleph::Array< T >::reserve(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min(), and Aleph::Array< T >::swap().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull().
|
inlineprivate |
Definition at line 175 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivatenoexcept |
Definition at line 259 of file tpl_bplus_tree.H.
References Aleph::Array< T >::get_last(), Aleph::Array< T >::is_empty(), Aleph::detail::BPlusTreeNode< Key >::keys, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rightmost_leaf().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::max_key(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivate |
Definition at line 267 of file tpl_bplus_tree.H.
References ah_runtime_error_unless, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min_ptr().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::rebuild_separators(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child().
|
inlineprivatenoexcept |
Definition at line 251 of file tpl_bplus_tree.H.
References Aleph::Array< T >::get_first(), Aleph::Array< T >::is_empty(), Aleph::detail::BPlusTreeNode< Key >::keys, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::leftmost_leaf().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::min_key(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlinenoexcept |
Exchange the keys and the comparators of this tree and another.
| other | Tree to exchange with. |
| Whatever | swapping the comparators throws. They are exchanged first, so that, if that swap throws, nothing else is exchanged, and both trees are left as they were if it left its arguments as they were. |
Definition at line 852 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::swap().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::operator=(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::swap().
|
inlinestaticprivate |
Definition at line 215 of file tpl_bplus_tree.H.
References Aleph::Array< T >::remove_last(), and Aleph::Array< T >::size().
|
inline |
Return the first key strictly greater than key.
| key | Probe key. |
std::nullopt if none exists. | Any | exception propagated by Compare or Key copy construction. |
Definition at line 1078 of file tpl_bplus_tree.H.
References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::find_leaf(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), Aleph::detail::BPlusTreeNode< Key >::next, Aleph::Array< T >::size(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound_index().
|
inlineprivate |
Definition at line 157 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::equals(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::child_index(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound().
|
inline |
Verify structural B+ Tree invariants.
true if the tree is structurally valid, otherwise false. | Any | exception propagated by Compare. |
Definition at line 1154 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_leaf_chain(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivate |
Definition at line 534 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Array< T >::get_first(), Aleph::Array< T >::get_last(), Aleph::Array< T >::is_empty(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::leftmost_leaf(), Aleph::detail::BPlusTreeNode< Key >::next, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size_.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify().
|
inlineprivate |
Definition at line 567 of file tpl_bplus_tree.H.
References Aleph::and, Aleph::detail::BPlusTreeNode< Key >::children, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::equals(), Aleph::Array< T >::get_first(), Aleph::Array< T >::get_last(), Aleph::Array< T >::is_empty(), Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), Aleph::detail::BPlusTreeNode< Key >::leaf, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::max_key(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MaxKeys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::min_key(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::MinKeys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::root_, Aleph::Array< T >::size(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::strictly_sorted(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_max_ptr(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::subtree_min_ptr(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
private |
Definition at line 147 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::Iterator(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::equals(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::key_comp(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::operator=(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::skip_past_end(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::strictly_sorted(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::swap(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::upper_bound_index(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_leaf_chain(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
staticconstexprprivate |
Definition at line 142 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
staticconstexprprivate |
Definition at line 143 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::fix_underflow(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::split_child(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
private |
Definition at line 145 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Gen_BPlus_Tree(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::clear(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::contains(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::find_leaf(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::height(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::max_key(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::min_key(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::operator=(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::swap(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_leaf_chain(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_node().
|
private |
Definition at line 146 of file tpl_bplus_tree.H.
Referenced by Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::clear(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::empty(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::insert(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::keys(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::operator=(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::remove(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::size(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::swap(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::verify_leaf_chain().