Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator Class Reference

Lazy iterator over ordered leaf keys. More...

#include <tpl_bplus_tree.H>

Collaboration diagram for Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator:
[legend]

Public Member Functions

 Iterator () noexcept=default
 Construct an exhausted iterator.
 
 Iterator (const Gen_BPlus_Tree &tree) noexcept
 Construct an iterator over the full key order.
 
 Iterator (const Gen_BPlus_Tree &tree, const Key &first, const Key &last)
 Construct an iterator over the inclusive range [first, last].
 
bool has_curr () const noexcept
 Return whether the iterator still points to a key.
 
const Key & get_curr () const
 Return the current key.
 
void next_ne ()
 Advance to the next key.
 
void next ()
 Synonym for next_ne().
 
const Key & operator* () const
 Dereference the iterator.
 
const Key * operator-> () const
 Member-access shorthand for the current key.
 

Private Member Functions

void skip_past_end ()
 

Private Attributes

const Gen_BPlus_Treetree_ = nullptr
 
const Nodeleaf_ = nullptr
 
size_t idx_ = 0
 
std::optional< Key > last_
 

Detailed Description

template<typename Key, class Compare = Aleph::less<Key>, size_t MinDegree = 16>
class Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator

Lazy iterator over ordered leaf keys.

The iterator walks the leaf chain directly and therefore avoids materializing an intermediate Array<Key>. Any mutation of the owning tree invalidates all iterators.

Definition at line 606 of file tpl_bplus_tree.H.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::Iterator ( )
defaultnoexcept

Construct an exhausted iterator.

Exceptions
Nothing.

◆ Iterator() [2/3]

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::Iterator ( const Gen_BPlus_Tree tree)
inlineexplicitnoexcept

Construct an iterator over the full key order.

Parameters
treeTree whose leaf chain will be traversed.
Exceptions
Nothing.

Definition at line 643 of file tpl_bplus_tree.H.

References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::skip_past_end().

◆ Iterator() [3/3]

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::Iterator ( const Gen_BPlus_Tree tree,
const Key &  first,
const Key &  last 
)
inline

Construct an iterator over the inclusive range [first, last].

Parameters
treeTree whose leaf chain will be traversed.
firstLower bound, inclusive.
lastUpper bound, inclusive.
Exceptions
std::invalid_argumentIf last < first.
Anyexception propagated by Compare.

Definition at line 656 of file tpl_bplus_tree.H.

References ah_invalid_argument_if, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::cmp_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::find_leaf(), Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::idx_, Aleph::detail::BPlusTreeNode< Key >::keys, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::leaf_, Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::lower_bound_index(), and Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::skip_past_end().

Member Function Documentation

◆ get_curr()

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
const Key & Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::get_curr ( ) const
inline

◆ has_curr()

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
bool Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::has_curr ( ) const
inlinenoexcept

◆ next()

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
void Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::next ( )
inline

Synonym for next_ne().

Exceptions
std::underflow_errorIf the iterator is exhausted.
Anyexception propagated by Compare.

Definition at line 702 of file tpl_bplus_tree.H.

References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::next_ne().

◆ next_ne()

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
void Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::next_ne ( )
inline

◆ operator*()

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
const Key & Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::operator* ( ) const
inline

Dereference the iterator.

Returns
Reference to the current key.
Exceptions
std::underflow_errorIf the iterator is exhausted.

Definition at line 711 of file tpl_bplus_tree.H.

References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::get_curr().

◆ operator->()

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
const Key * Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::operator-> ( ) const
inline

Member-access shorthand for the current key.

Returns
Pointer to the current key.
Exceptions
std::underflow_errorIf the iterator is exhausted.

Definition at line 720 of file tpl_bplus_tree.H.

References Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::get_curr().

◆ skip_past_end()

Member Data Documentation

◆ idx_

◆ last_

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
std::optional<Key> Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::last_
private

◆ leaf_

◆ tree_

template<typename Key , class Compare = Aleph::less<Key>, size_t MinDegree = 16>
const Gen_BPlus_Tree* Aleph::Gen_BPlus_Tree< Key, Compare, MinDegree >::Iterator::tree_ = nullptr
private

The documentation for this class was generated from the following file: