|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Const bidirectional iterator for in-order traversal. More...
#include <jh/core/ordered_map.h>
Public Types | |
| using | base_type = tree_map |
| Owning tree type. | |
| using | node_type = detail::node_t<K, V> |
| Canonical node type used internally. | |
| using | stored_type = detail::base_t<K, V> |
| Stored value type (key for set, pair<const K,V> for map). | |
| using | iterator_concept = std::bidirectional_iterator_tag |
| Iterator concept tag (bidirectional). | |
| using | value_type = stored_type |
| Value type produced when dereferenced. | |
| using | reference = const stored_type & |
| Reference type for dereferencing. | |
| using | pointer = const stored_type * |
| Pointer type for dereferencing. | |
| using | difference_type = std::int64_t |
| Difference type used for iterator arithmetic. | |
Public Member Functions | |
| const_iterator ()=default | |
| Construct a singular iterator. | |
| const_iterator (const base_type *t, std::size_t i) | |
| Construct an iterator referring to the given node index. | |
| const_iterator (const iterator &it) | |
| Construct a const_iterator from a non-const iterator. | |
| reference | operator* () const |
| Dereference the iterator. | |
| pointer | operator-> () const |
| Access the referenced element via pointer. | |
| const node_type::key_type & | key () const |
| Obtain the key of the referenced element. | |
| const_iterator & | operator++ () |
| Advance to the in-order successor. | |
| const_iterator | operator++ (int) |
| Post-increment. | |
| const_iterator & | operator-- () |
| Move to the in-order predecessor. | |
| const_iterator | operator-- (int) |
| Post-decrement. | |
| bool | operator== (const const_iterator &other) const |
| Compare two const_iterators for equality. | |
| bool | operator!= (const const_iterator &other) const |
| Compare two const_iterators for inequality. | |
Public Attributes | |
| const base_type * | tree = nullptr |
Associated tree instance; nullptr indicates a singular iterator. | |
| std::size_t | idx = static_cast<std::size_t>(-1) |
Index of the referenced node, or -1 for end(). | |
Const bidirectional iterator for in-order traversal.
Unlike iterator, this type provides a strictly read-only view of the underlying elements. All dereference operations yield const access, and mutation through the iterator is not permitted. This mirrors the behavior of standard associative-container const_iterator.
Conversion from iterator to const_iterator is supported, but not the reverse. Aside from const-qualification, traversal semantics (increment, decrement, ordering) match those of iterator.
|
default |
Construct a singular iterator.
A default-constructed const_iterator does not refer to any tree and is therefore singular. It must not be incremented, decremented, or dereferenced. Only assignment or destruction is permitted.
This state is distinct from end(): an end iterator is bound to a specific container and supports valid bidirectional traversal (e.g., –end()), while a singular iterator does not.
|
inline |
Construct an iterator referring to the given node index.
| t | Pointer to the owning tree. |
| i | Node index, or -1 to represent end(). |
This constructor is typically used internally to form begin/end iterators. Users generally obtain iterators through member functions.
|
inlineexplicit |
Construct a const_iterator from a non-const iterator.
| it | The iterator to convert. |
Enables implicit promotion from iterator to const_iterator, matching standard iterator behavior for associative containers.
|
inlinenodiscard |
Obtain the key of the referenced element.
Undefined behavior if the iterator is singular or equals end().
|
inline |
Compare two const_iterators for inequality.
Equivalent to !(a == b).
true if the iterators are not equal.
|
inline |
Dereference the iterator.
Undefined behavior if the iterator is singular or equals end().
|
inline |
Advance to the in-order successor.
Bidirectional-iterator semantics apply:
end(), incrementing leaves it unchanged. *this.
|
inline |
Post-increment.
Returns the prior iterator value, then advances using operator++().
|
inline |
Move to the in-order predecessor.
Bidirectional-iterator semantics apply:
end(), decrementing moves it to the last element, or leaves it unchanged if the container is empty. begin(), decrementing moves it to end(). *this.
|
inline |
Post-decrement.
Returns the prior iterator value, then decrements using operator--().
|
inline |
Access the referenced element via pointer.
Undefined behavior if the iterator is singular or equals end().
|
inline |
Compare two const_iterators for equality.
| other | The iterator to compare with. |
Two const_iterators are equal only if they refer to the same container and the same logical position.