|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Base iterator template for ranked binary search trees. More...
#include <tpl_binNodeXt.H>
Public Member Functions | |
| BinTreeXt_Iterator () noexcept | |
| BinTreeXt_Iterator (const TreeType &__tree) noexcept | |
| BinTreeXt_Iterator (const TreeType &__tree, Node *__curr) noexcept | |
| BinTreeXt_Iterator (const TreeType &__tree, const size_t pos) noexcept | |
Initialize an iterator on the inorder position pos. | |
| BinTreeXt_Iterator (const BinTreeXt_Iterator &itor) noexcept | |
| BinTreeXt_Iterator & | operator= (const BinTreeXt_Iterator &itor) noexcept |
| void | reset_first () noexcept |
| void | reset_last () noexcept |
| void | end () noexcept |
| void | reset_to_key (const Key &key) noexcept(noexcept(tree_ptr->find_position(key))) |
| Put the iterator on the node of a key. | |
| void | reset_to_node (Node *node) noexcept |
| void | reset_to_pos (const size_t pos) noexcept |
Put the iterator on the inorder position pos. | |
| Node * | get_curr_ne () const noexcept |
| Return the current node. | |
| Node * | get_curr () const noexcept |
| Return the current node. | |
| size_t | get_current_position () const |
| size_t | get_pos () const |
| bool | has_curr () const noexcept(nothrow_compare_v< Compare, Key >) |
Return true if the iterator has a current node. | |
| void | prev () |
| void | next_ne () noexcept |
| Move the iterator one position forward, without the check of next(). | |
| void | next () |
| Node * | del () |
| bool | operator== (const BinTreeXt_Iterator &itor) const noexcept(nothrow_compare_v< Compare, Key >) |
Return true if this and itor are on the same position. | |
| bool | operator!= (const BinTreeXt_Iterator &itor) const |
Protected Attributes | |
| TreeType * | tree_ptr |
| Node * | curr |
| int | curr_pos |
Static Protected Attributes | |
| static constexpr int | Pos_Not_Current = -1 |
| static constexpr int | Pos_Empty_Container = -2 |
| static constexpr int | Pos_Not_Updated = -3 |
| static constexpr int | Pos_Out_Of_Range = std::numeric_limits<int>::min() |
Private Member Functions | |
| bool | is_container_empty () const noexcept |
| bool | pos_updated () const noexcept |
| bool | curr_updated () const noexcept |
| void | update_pos () const noexcept(nothrow_compare_v< Compare, Key >) |
| void | update_curr () const noexcept |
Static Private Member Functions | |
| static int | saturated_pos (const size_t pos) noexcept |
Base iterator template for ranked binary search trees.
This template provides a common implementation for iterators on trees that support O(log n) select and position operations via subtree counters.
The TreeType must provide:
| TreeType | the tree class type |
| Node | the node type |
| Key | the key type |
| Compare | comparison functor |
Definition at line 1163 of file tpl_binNodeXt.H.
|
inlinenoexcept |
Definition at line 1245 of file tpl_binNodeXt.H.
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 1255 of file tpl_binNodeXt.H.
|
inlinenoexcept |
Initialize an iterator on the inorder position pos.
| [in] | __tree | the tree to iterate |
| [in] | pos | inorder position; at size() or past it, the iterator is at the end, without current node, even if an int cannot hold it. |
Definition at line 1266 of file tpl_binNodeXt.H.
|
inlinenoexcept |
Definition at line 1271 of file tpl_binNodeXt.H.
|
inlineprivatenoexcept |
Definition at line 1188 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::del(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_curr_ne(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator==().
|
inline |
Definition at line 1428 of file tpl_binNodeXt.H.
References ah_underflow_error_if, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_updated(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), KEY, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr().
|
inlinenoexcept |
Definition at line 1300 of file tpl_binNodeXt.H.
References put_itor_at_the_end().
|
inlinenoexcept |
Return the current node.
nullptr if there is none. Definition at line 1365 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_curr_ne().
|
inlinenoexcept |
Return the current node.
A position past the end has no node, whichever way the iterator got there: then it gives nullptr, without the check of select(), which would throw. A node that the iterator already found stays its current one, though: if the tree changes, as when keys before it are removed, it may give that node while has_curr() is false. A change of the tree invalidates the iterator, which must then be put on a position again.
nullptr if there is none. Definition at line 1353 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_updated(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr().
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_curr().
|
inline |
Definition at line 1370 of file tpl_binNodeXt.H.
References ah_range_error_if, Aleph::COUNT(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::pos_updated(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos().
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_pos().
|
inline |
Definition at line 1382 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_current_position().
|
inlinenoexcept |
Return true if the iterator has a current node.
true if the position of the iterator has a node. | anything | that the comparison throws while it computes the position of a node that the iterator was put on, as reset_to_node() does. It is noexcept only if the comparison cannot throw, so that what it throws reaches the caller. |
Definition at line 1392 of file tpl_binNodeXt.H.
References Aleph::and, Aleph::COUNT(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::pos_updated(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos().
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::del(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::next(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::prev().
|
inlineprivatenoexcept |
Definition at line 1178 of file tpl_binNodeXt.H.
References Aleph::COUNT(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::BinTreeXt_Iterator(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator==(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_first(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_last().
|
inline |
Definition at line 1422 of file tpl_binNodeXt.H.
References ah_overflow_error_if, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::next_ne().
|
inlinenoexcept |
Move the iterator one position forward, without the check of next().
Past the end it goes on to positions without node. It adds 1 as an unsigned: from the greatest int, which a position given near it reaches past the end, it goes to Pos_Out_Of_Range, the least int, instead of overflowing.
Definition at line 1416 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::next().
|
inline |
Definition at line 1472 of file tpl_binNodeXt.H.
|
inlinenoexcept |
|
inlinenoexcept |
Return true if this and itor are on the same position.
| [in] | itor | the iterator to compare with. |
true if both iterators are on the same position. | anything | that the comparison throws while it computes the position of a node that an iterator was put on. It is noexcept only if the comparison cannot throw, so that what it throws reaches the caller. |
Definition at line 1450 of file tpl_binNodeXt.H.
References Aleph::and, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_updated(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::is_container_empty(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::pos_updated(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos().
|
inlineprivatenoexcept |
Definition at line 1183 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::Pos_Not_Updated.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_current_position(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator==().
|
inline |
|
inlinenoexcept |
Definition at line 1287 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::is_container_empty(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::Pos_Empty_Container.
|
inlinenoexcept |
Definition at line 1293 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::is_container_empty(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::Pos_Empty_Container, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr.
|
inlinenoexcept |
Put the iterator on the node of a key.
The node that the iterator had is dropped, so that get_curr() gives the node of the new position, not the previous one.
| [in] | key | to guide the position; if it is not in the tree, the position is the one that the find_position() of the tree gives. |
| anything | that find_position() of the tree throws, as what the comparison throws; then the iterator is left as it was. It is noexcept only if find_position() is. |
Definition at line 1316 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr.
|
inlinenoexcept |
|
inlinenoexcept |
Put the iterator on the inorder position pos.
| [in] | pos | inorder position; at size() or past it, the iterator is at the end, without current node, even if an int cannot hold it. |
Definition at line 1335 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::saturated_pos().
|
inlinestaticprivatenoexcept |
Definition at line 1211 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::Pos_Out_Of_Range.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_pos().
|
inlineprivatenoexcept |
Definition at line 1223 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::Pos_Not_Updated, root(), Aleph::select_ne(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::del(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_curr_ne().
|
inlineprivatenoexcept |
Definition at line 1198 of file tpl_binNodeXt.H.
References Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr, Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_pos, Aleph::inorder_position_of_node(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::tree_ptr.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_current_position(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator==().
|
mutableprotected |
Definition at line 1168 of file tpl_binNodeXt.H.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::curr_updated(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::del(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_curr_ne(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::next_ne(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator=(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator==(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::prev(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_first(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_last(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_key(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_node(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_pos(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos().
|
mutableprotected |
Definition at line 1169 of file tpl_binNodeXt.H.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::BinTreeXt_Iterator(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_current_position(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::next_ne(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator=(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator==(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::pos_updated(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::prev(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_first(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_last(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_key(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_node(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_pos(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos().
|
staticconstexprprotected |
|
staticconstexprprotected |
Definition at line 1171 of file tpl_binNodeXt.H.
|
staticconstexprprotected |
|
staticconstexprprotected |
Definition at line 1174 of file tpl_binNodeXt.H.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::saturated_pos().
|
mutableprotected |
Definition at line 1167 of file tpl_binNodeXt.H.
Referenced by Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::del(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_current_position(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::is_container_empty(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::operator=(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_last(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_to_key(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr(), and Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos().