Concept Subspace :: sus :: iter :: DoubleEndedIterator
template <class T, class Item = typename std::remove_cvref_t<T>::Item>concept DoubleEndedIterator
requires
sus::iter::Iterator<T, Item>
requires(std::remove_cvref_t<T>& t) {
{ t.next_back() } noexcept -> std::same_as<::sus::option::Option<Item>>;
}
An Iterator
able to yield elements from both ends.
Something that implements DoubleEndedIterator
has one extra capability
over something that implements Iterator
: the ability to also take Items
from the back, as well as the front.
It is important to note that both back and forth work on the same range, and do not cross: iteration is over when they meet in the middle.
In a similar fashion to the Iterator
protocol,
once a
DoubleEndedIterator
returns None
from a next_back()
, calling it again
may or may not ever return Some
again. next()
and next_back()
are
interchangeable for this purpose.
Required methods.
A DoubleEndedIterator
has one required methods, in addition to those
required by Iterator
.
auto next_back() -> Option<Item>
returns anOption
containing the nextItem
from the back of the iterator as long as there are elements, and once they've all been exhausted, will returnNone
to indicate that iteration is finished.