Stroika Library 3.0d24
 
Loading...
Searching...
No Matches
BidirectionalIterator.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
5
6namespace Stroika::Foundation::Traversal {
7
8 /*
9 ********************************************************************************
10 ****************** BidirectionalIterator<T, ITERATOR_TRAITS> *******************
11 ********************************************************************************
12 */
13 template <typename T, typename ITERATOR_TRAITS>
14 inline BidirectionalIterator<T, ITERATOR_TRAITS>::BidirectionalIterator (const unique_ptr<IRep>& rep) noexcept
15 : inherited{rep}
16 {
17 }
18 template <typename T, typename ITERATOR_TRAITS>
19 inline BidirectionalIterator<T, ITERATOR_TRAITS>::BidirectionalIterator (unique_ptr<IRep>&& rep) noexcept
20 : inherited{move (rep)}
21 {
22 }
23 template <typename T, typename ITERATOR_TRAITS>
24 constexpr BidirectionalIterator<T, ITERATOR_TRAITS>::BidirectionalIterator (const default_sentinel_t&) noexcept
25 : inherited{default_sentinel}
26 {
27 }
28 template <typename T, typename ITERATOR_TRAITS>
29 constexpr BidirectionalIterator<T, ITERATOR_TRAITS>::BidirectionalIterator (nullptr_t) noexcept
30 : inherited{nullptr}
31 {
32 }
33 template <typename T, typename ITERATOR_TRAITS>
34 constexpr BidirectionalIterator<T, ITERATOR_TRAITS>::BidirectionalIterator () noexcept
35 : inherited{}
36 {
37 }
38 template <typename T, typename ITERATOR_TRAITS>
39 inline bool BidirectionalIterator<T, ITERATOR_TRAITS>::AtStart () const
40 {
41 return ConstGetRep ().AtStart ();
42 }
43 template <typename T, typename ITERATOR_TRAITS>
45 {
46 inherited::operator++ ();
47 return *this;
48 }
49 template <typename T, typename ITERATOR_TRAITS>
51 {
52 auto result = *this;
53 inherited::operator++ ();
54 return result;
55 }
56 template <typename T, typename ITERATOR_TRAITS>
58 {
59 Require (not this->AtStart ());
60 this->_fCurrentValue = GetRep ().Back ();
61 return *this;
62 }
63 template <typename T, typename ITERATOR_TRAITS>
65 {
66 BidirectionalIterator result = *this;
67 --result;
68 return result;
69 }
70 template <typename T, typename ITERATOR_TRAITS>
72 {
73 Require (i >= 0);
74 BidirectionalIterator result{*this};
75 for (ptrdiff_t j = 0; j < i; ++j) {
76 --result;
77 }
78 return result;
79 }
80 template <typename T, typename ITERATOR_TRAITS>
82 {
83 return Debug::UncheckedDynamicCast<IRep&> (inherited::GetRep ());
84 }
85 template <typename T, typename ITERATOR_TRAITS>
87 {
88 return Debug::UncheckedDynamicCast<const IRep&> (inherited::ConstGetRep ());
89 }
90
91}
An Iterator<T> that also supports going backwards.
A BidirectionalIterator is an Iterator that can be moved both forward and backward.
nonvirtual const IRep & ConstGetRep() const
Get a reference to the IRep owned by the iterator. This is an implementation detail,...
nonvirtual IRep & GetRep()
Get a reference to the IRep owned by the iterator. This is an implementation detail,...
nonvirtual BidirectionalIterator & operator++()
same as Iterator::operator++ () - advances iterator - but returns the subclass iterator type.
nonvirtual BidirectionalIterator operator-(ptrdiff_t i) const
Move the iterator back by the specified number of positions.
An Iterator<T> is a copyable object which allows traversing the contents of some container.
Definition Iterator.h:253