|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Generic B-Tree with configurable minimum degree. More...
#include <tpl_b_tree.H>
Public Types | |
| using | key_type = Key |
| Stored key type. | |
Public Member Functions | |
| Gen_B_Tree (const Compare &cmp=Compare()) | |
| Construct an empty B-Tree. | |
| template<std::input_iterator It> | |
| Gen_B_Tree (It first, It last, const Compare &cmp=Compare()) | |
| Construct a B-Tree from an iterator range. | |
| Gen_B_Tree (std::initializer_list< Key > init, const Compare &cmp=Compare()) | |
| Construct a B-Tree from an initializer list. | |
| Gen_B_Tree (const Gen_B_Tree &other) | |
| Copy constructor performing a deep copy. | |
| Gen_B_Tree (Gen_B_Tree &&other) noexcept(std::is_nothrow_copy_constructible_v< Compare >) | |
| Move constructor: take the keys of another tree, which is left empty. | |
| Gen_B_Tree & | operator= (const Gen_B_Tree &other) |
| Copy assignment. | |
| Gen_B_Tree & | operator= (Gen_B_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_B_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. | |
| Array< Key > | keys () const |
| Materialize the tree contents in sorted order. | |
| bool | verify () const |
| Verify structural B-Tree invariants. | |
Private Types | |
| using | Node = detail::BTreeNode< 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 |
| bool | equals (const Key &lhs, const Key &rhs) const |
| template<std::input_iterator It> | |
| void | insert_range (It first, It last) |
| std::unique_ptr< Node > | clone_node (const Node *node) const |
| size_t | height_of (const Node *node) const noexcept |
| 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) |
| std::optional< Key > | min_in (const Node *node) const |
| std::optional< Key > | max_in (const Node *node) const |
| 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 idx) |
| size_t | ensure_child_has_extra (Node *parent, const size_t idx) |
| bool | remove_from (Node *node, const Key &key) |
| void | collect_keys (const Node *node, Array< Key > &out) 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_B_Tree models an ordered set of unique keys. Unlike the raw binary-tree types in Aleph-w, this container owns its internal nodes and stores keys directly in them, which makes it a higher-level tree suited for page-like branching factors.
| 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. |
false. Compare and Key operations do not throw in the middle of internal node updates; allocation failures propagate as std::bad_alloc. Definition at line 134 of file tpl_b_tree.H.
| using Aleph::Gen_B_Tree< Key, Compare, MinDegree >::key_type = Key |
Stored key type.
Definition at line 555 of file tpl_b_tree.H.
|
private |
Definition at line 139 of file tpl_b_tree.H.
|
inlineexplicit |
Construct an empty B-Tree.
| cmp | Comparison functor used to sort keys. |
| Nothing. |
Definition at line 562 of file tpl_b_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 571 of file tpl_b_tree.H.
References Aleph::Gen_B_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 582 of file tpl_b_tree.H.
|
inline |
Copy constructor performing a deep copy.
| other | Tree to copy. |
| std::bad_alloc | if cloning internal nodes fails. |
Definition at line 591 of file tpl_b_tree.H.
|
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 604 of file tpl_b_tree.H.
|
inlinestaticprivate |
Definition at line 219 of file tpl_b_tree.H.
References Aleph::Array< T >::append(), Aleph::Array< T >::reserve(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::merge_children(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child().
|
inlinestaticprivate |
Definition at line 226 of file tpl_b_tree.H.
References Aleph::Array< T >::append(), Aleph::Array< T >::reserve(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::merge_children(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child().
|
inlineprivate |
Definition at line 370 of file tpl_b_tree.H.
References Aleph::Array< T >::append(), Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::erase_at(), Aleph::Array< T >::get_first(), Aleph::detail::BTreeNode< Key >::keys, and Aleph::detail::BTreeNode< Key >::leaf.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::ensure_child_has_extra().
|
inlineprivate |
Definition at line 354 of file tpl_b_tree.H.
References Aleph::detail::BTreeNode< Key >::children, Aleph::Array< T >::get_last(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_at(), Aleph::detail::BTreeNode< Key >::keys, Aleph::detail::BTreeNode< Key >::leaf, and Aleph::Array< T >::remove_last().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::ensure_child_has_extra().
|
inlinenoexcept |
Remove every key from the tree.
| Nothing. |
Definition at line 721 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_.
|
inlineprivate |
Definition at line 233 of file tpl_b_tree.H.
References Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::clone_node(), Aleph::copy(), Aleph::detail::BTreeNode< Key >::keys, Aleph::detail::BTreeNode< Key >::leaf, and Aleph::Array< T >::reserve().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::clone_node().
|
inlineprivate |
Definition at line 472 of file tpl_b_tree.H.
References Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::collect_keys(), Aleph::detail::BTreeNode< Key >::keys, Aleph::detail::BTreeNode< Key >::leaf, out, and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::collect_keys(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys().
|
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 733 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains_in(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::search().
|
inlineprivate |
Definition at line 262 of file tpl_b_tree.H.
References Aleph::and, Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::equals(), Aleph::detail::BTreeNode< Key >::keys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), Aleph::detail::BTreeNode< Key >::leaf, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound_index(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains().
|
inlinenoexcept |
Return whether the tree has no keys.
true if empty, otherwise false. | Nothing. |
Definition at line 682 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::is_empty().
|
inlineprivate |
Definition at line 401 of file tpl_b_tree.H.
References Aleph::and, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::borrow_from_next(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::borrow_from_prev(), Aleph::detail::BTreeNode< Key >::children, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::merge_children().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inlineprivate |
Definition at line 176 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, and Aleph::detail::equiv().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains_in(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inlinestaticprivate |
Definition at line 201 of file tpl_b_tree.H.
References Aleph::close_gap(), Aleph::Array< T >::remove_last(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::borrow_from_next(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::merge_children(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inlinenoexcept |
Return the comparison object (read-only).
| Nothing. |
Definition at line 672 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::key_comp().
|
inlinenoexcept |
Return the current tree height.
0 for an empty tree, otherwise the number of node levels. | Nothing. |
Definition at line 712 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::height_of(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::height_of().
|
inlineprivatenoexcept |
Definition at line 249 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::height().
Referenced by Aleph::Gen_B_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 756 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::MaxKeys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_B_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 789 of file tpl_b_tree.H.
References Aleph::copy(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert().
|
inlinestaticprivate |
Definition at line 187 of file tpl_b_tree.H.
References Aleph::Array< T >::append(), Aleph::open_gap(), Aleph::Array< T >::putn(), Aleph::Array< T >::size(), and value.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::borrow_from_prev(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child().
|
inlineprivate |
Definition at line 297 of file tpl_b_tree.H.
References Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_at(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::detail::BTreeNode< Key >::keys, Aleph::detail::BTreeNode< Key >::leaf, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::MaxKeys, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull().
|
inlineprivate |
Definition at line 181 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::Gen_B_Tree().
|
inlinenoexcept |
Synonym for empty() in traditional Aleph style.
true if empty, otherwise false. | Nothing. |
Definition at line 692 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::empty().
|
inlinenoexcept |
Return the comparison object (read-only).
| Nothing. |
Definition at line 662 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_.
Referenced by Aleph::Gen_B_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 910 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::collect_keys(), out, Aleph::Array< T >::reserve(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains_in(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::upper_bound(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::upper_bound_index(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
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 862 of file tpl_b_tree.H.
References Aleph::detail::BTreeNode< Key >::children, Aleph::detail::BTreeNode< Key >::keys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), Aleph::detail::BTreeNode< Key >::leaf, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, and Aleph::Array< T >::size().
|
inlineprivate |
Definition at line 148 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains_in(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inlineprivate |
Definition at line 335 of file tpl_b_tree.H.
References Aleph::and, Aleph::detail::BTreeNode< Key >::children, Aleph::Array< T >::get_last(), Aleph::Array< T >::is_empty(), Aleph::detail::BTreeNode< Key >::keys, and Aleph::detail::BTreeNode< Key >::leaf.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::max_key(), and Aleph::Gen_B_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 851 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::max_in(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivate |
Definition at line 386 of file tpl_b_tree.H.
References Aleph::Array< T >::append(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::append_copy_range(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::append_move_range(), Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::erase_at(), GenericItems< Container, T >::keys(), Aleph::detail::BTreeNode< Key >::keys, and Aleph::detail::BTreeNode< Key >::leaf.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::ensure_child_has_extra(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inlineprivate |
Definition at line 316 of file tpl_b_tree.H.
References Aleph::and, Aleph::detail::BTreeNode< Key >::children, Aleph::Array< T >::get_first(), Aleph::Array< T >::is_empty(), Aleph::detail::BTreeNode< Key >::keys, and Aleph::detail::BTreeNode< Key >::leaf.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::min_key(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inline |
Return the minimum key, if any.
std::nullopt if empty. | Any | exception propagated by Key copy construction. |
Definition at line 841 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::min_in(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
inline |
Copy assignment.
| other | Tree to copy from. |
*this. Definition at line 613 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_B_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 633 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::swap().
|
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 801 of file tpl_b_tree.H.
References Aleph::and, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_.
|
inlineprivate |
Definition at line 428 of file tpl_b_tree.H.
References ah_runtime_error_unless, Aleph::and, Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::ensure_child_has_extra(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::equals(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::erase_at(), Aleph::detail::BTreeNode< Key >::keys, Aleph::detail::BTreeNode< Key >::leaf, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::max_in(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::merge_children(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::min_in(), pred, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove_from().
|
inline |
Synonym for contains().
| key | Key to search. |
true if the key exists, otherwise false. | Any | exception propagated by Compare. |
Definition at line 744 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains().
|
inlinenoexcept |
Return the number of stored keys.
| Nothing. |
Definition at line 702 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_.
|
inlineprivate |
Definition at line 277 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::append_copy_range(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::append_move_range(), Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_at(), Aleph::detail::BTreeNode< Key >::keys, Aleph::detail::BTreeNode< Key >::leaf, Aleph::median(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::MinKeys, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::truncate().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull().
|
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 647 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::swap().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::operator=(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::swap().
|
inlinestaticprivate |
Definition at line 213 of file tpl_b_tree.H.
References Aleph::Array< T >::remove_last(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child().
|
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 886 of file tpl_b_tree.H.
References Aleph::detail::BTreeNode< Key >::children, Aleph::detail::BTreeNode< Key >::keys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), Aleph::detail::BTreeNode< Key >::leaf, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, Aleph::Array< T >::size(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::upper_bound_index().
|
inlineprivate |
Definition at line 162 of file tpl_b_tree.H.
References Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), and Aleph::Array< T >::size().
Referenced by Aleph::Gen_B_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 923 of file tpl_b_tree.H.
References Aleph::and, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size_, and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
inlineprivate |
Definition at line 492 of file tpl_b_tree.H.
References Aleph::and, Aleph::detail::BTreeNode< Key >::children, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Array< T >::get_first(), Aleph::Array< T >::get_last(), Aleph::Array< T >::is_empty(), Aleph::detail::BTreeNode< Key >::keys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), Aleph::detail::BTreeNode< Key >::leaf, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::max_key(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::MaxKeys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::min_key(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::MinKeys, Aleph::Gen_B_Tree< Key, Compare, MinDegree >::root_, Aleph::Array< T >::size(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
private |
Definition at line 146 of file tpl_b_tree.H.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::equals(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::key_comp(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound_index(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::operator=(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::swap(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::upper_bound_index(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
staticconstexprprivate |
Definition at line 141 of file tpl_b_tree.H.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert_nonfull(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
staticconstexprprivate |
Definition at line 142 of file tpl_b_tree.H.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::split_child(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
private |
Definition at line 144 of file tpl_b_tree.H.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::clear(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::contains(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::height(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::lower_bound(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::max_key(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::min_key(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::operator=(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::swap(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::upper_bound(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify_node().
|
private |
Definition at line 145 of file tpl_b_tree.H.
Referenced by Aleph::Gen_B_Tree< Key, Compare, MinDegree >::clear(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::empty(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::insert(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::keys(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::operator=(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::remove(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::size(), Aleph::Gen_B_Tree< Key, Compare, MinDegree >::swap(), and Aleph::Gen_B_Tree< Key, Compare, MinDegree >::verify().