|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Iterator on nodes of the tree. More...
#include <tpl_treapRk.H>
Public Member Functions | |
| Iterator () noexcept | |
| Iterator (const Gen_Treap_Rk &__tree) noexcept | |
Initialize an iterator on __tree | |
| Iterator (const Gen_Treap_Rk &__tree, Node *__curr) noexcept | |
Initialize an iterator starting from node __curr | |
| Iterator (const Gen_Treap_Rk &__tree, const size_t pos) noexcept | |
Initialize an iterator starting from the inorder position pos. | |
| Iterator (const Iterator &itor) noexcept | |
| Iterator & | operator= (const Iterator &itor) noexcept |
| void | reset_first () noexcept |
| Reset the iterator to the first position. | |
| void | reset_last () noexcept |
| Reset the iterator to the last position. | |
| void | end () noexcept |
| Put the iterator in the end state. | |
| 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 |
| Put the current node to a specific node. | |
| 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 |
| return the position of current node | |
| size_t | get_pos () const |
See get_current_position(). | |
| bool | has_curr () const noexcept(nothrow_compare_v< Compare, Key >) |
Return true if the iterator has a current node. | |
| void | prev () |
| Move the iterator one position backward. | |
| void | next_ne () noexcept |
| Move the iterator one position forward, without the check of next(). | |
| void | next () |
| Move the iterator one position forward. | |
| Node * | del () |
| Remove the current node and move the iterator one position forward. | |
| bool | operator== (const Iterator &itor) const noexcept(nothrow_compare_v< Compare, Key >) |
Return true if this and itor are on the same position. | |
| bool | operator!= (const Iterator &itor) const |
Return true if this is not equal to itor | |
| bool | verify (Gen_Treap_Rk *r) const noexcept |
| bool | verify (const Iterator &it) const noexcept |
Protected Attributes | |
| Gen_Treap_Rk * | 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 |
| bool | is_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 |
Iterator on nodes of the tree.
The visit order is inorder.
Definition at line 947 of file tpl_treapRk.H.
|
inlinenoexcept |
Definition at line 1032 of file tpl_treapRk.H.
|
inlinenoexcept |
Initialize an iterator on __tree
Definition at line 1039 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Empty_Container.
|
inlinenoexcept |
Initialize an iterator starting from node __curr
Definition at line 1046 of file tpl_treapRk.H.
|
inlinenoexcept |
Initialize an iterator starting from 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 1060 of file tpl_treapRk.H.
|
inlinenoexcept |
Definition at line 1067 of file tpl_treapRk.H.
|
inlineprivatenoexcept |
Definition at line 972 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::del(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr_ne(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator==().
|
inline |
Remove the current node and move the iterator one position forward.
Definition at line 1254 of file tpl_treapRk.H.
References ah_underflow_error_if, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), KEY, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr().
|
inlinenoexcept |
Put the iterator in the end state.
Definition at line 1101 of file tpl_treapRk.H.
References put_itor_at_the_end().
|
inlinenoexcept |
Return the current node.
nullptr if there is none. Definition at line 1177 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::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 1164 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr().
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr().
|
inline |
return the position of current node
| underflow_error | if the iterator has not current node after a prev() operation |
| overflow_error | if the iterator has not current node after a next() operation |
Definition at line 1190 of file tpl_treapRk.H.
References ah_range_error_if, Aleph::COUNT(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_pos().
|
inline |
Definition at line 1203 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::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 1213 of file tpl_treapRk.H.
References Aleph::and, Aleph::COUNT(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::del(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::prev().
|
inlineprivatenoexcept |
Definition at line 962 of file tpl_treapRk.H.
References Aleph::COUNT(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator==(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_first(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_last().
|
inlineprivatenoexcept |
Definition at line 977 of file tpl_treapRk.H.
References Aleph::and, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated().
|
inline |
Move the iterator one position forward.
Throws overflow_error if there is no current
Definition at line 1247 of file tpl_treapRk.H.
References ah_underflow_error_if, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::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 1239 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next().
|
inline |
Return true if this is not equal to itor
Definition at line 1301 of file tpl_treapRk.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 1277 of file tpl_treapRk.H.
References Aleph::and, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().
|
inlineprivatenoexcept |
Definition at line 967 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Not_Updated.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_current_position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator==().
|
inline |
Move the iterator one position backward.
Throws underflow_error if there is no current
Definition at line 1223 of file tpl_treapRk.H.
References ah_underflow_error_if, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr().
|
inlinenoexcept |
Reset the iterator to the first position.
Definition at line 1086 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Empty_Container.
|
inlinenoexcept |
Reset the iterator to the last position.
Definition at line 1093 of file tpl_treapRk.H.
References Aleph::COUNT(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Empty_Container, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::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 find_position() gives. |
| anything | that find_position() throws, as what the comparison or its copy throws; then the iterator is left as it was. It is noexcept only if find_position() is. |
Definition at line 1117 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::find_position(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.
|
inlinenoexcept |
Put the current node to a specific node.
Its position is computed when it is needed, as Iterator(tree, node) does: marked as the position of an empty tree, has_curr() would be false.
| [in] | node | to put as current |
node is a node of the tree, not nullptr. Definition at line 1134 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Not_Updated.
|
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 1146 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::saturated_pos().
|
inlinestaticprivatenoexcept |
Definition at line 998 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Out_Of_Range.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_pos().
|
inlineprivatenoexcept |
Definition at line 1010 of file tpl_treapRk.H.
References Aleph::COUNT(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Not_Updated, root(), Aleph::select_ne(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::del(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr_ne().
|
inlineprivatenoexcept |
Definition at line 985 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::cmp, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::inorder_position_of_node(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_current_position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator==().
|
inlinenoexcept |
Definition at line 1311 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.
|
inlinenoexcept |
Definition at line 1306 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::r, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.
|
mutableprotected |
Definition at line 952 of file tpl_treapRk.H.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::del(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr_ne(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next_ne(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator=(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator==(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::prev(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_first(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_last(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_key(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_node(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().
|
mutableprotected |
Definition at line 953 of file tpl_treapRk.H.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_current_position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next_ne(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator=(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator==(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::prev(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_first(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_last(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_key(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_node(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().
|
staticconstexprprotected |
|
staticconstexprprotected |
Definition at line 955 of file tpl_treapRk.H.
|
staticconstexprprotected |
|
staticconstexprprotected |
Definition at line 958 of file tpl_treapRk.H.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::saturated_pos().
|
mutableprotected |
Definition at line 951 of file tpl_treapRk.H.
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::del(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_current_position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator=(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_last(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_key(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::verify(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::verify().