Stroika Library 3.0d24
 
Loading...
Searching...
No Matches
Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS > Class Template Reference

A BidirectionalIterator is an Iterator that can be moved both forward and backward. More...

#include <BidirectionalIterator.h>

Inheritance diagram for Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >:
Stroika::Foundation::Traversal::Iterator< T, ITERATOR_TRAITS > Stroika::Foundation::Containers::DataStructures::STLContainerWrapper< STL_CONTAINER_OF_T >::RandomAccessIterator Stroika::Foundation::Traversal::RandomAccessIterator< T, ITERATOR_TRAITS >

Classes

class  IRep
 An Iterator<T> that also supports going backwards. More...
 

Public Types

using iterator_category = bidirectional_iterator_tag
 
- Public Types inherited from Stroika::Foundation::Traversal::Iterator< T, ITERATOR_TRAITS >
using difference_type = typename ITERATOR_TRAITS::difference_type
 difference_type = typename ITERATOR_TRAITS::difference_type;
 
using value_type = typename ITERATOR_TRAITS::value_type
 value_type = typename ITERATOR_TRAITS::value_type;
 
using pointer = typename ITERATOR_TRAITS::pointer
 pointer = typename ITERATOR_TRAITS::pointer;
 
using reference = typename ITERATOR_TRAITS::reference
 reference = typename ITERATOR_TRAITS::reference;
 
using iterator_category = forward_iterator_tag
 iterator_category = forward_iterator_tag;
 

Public Member Functions

 BidirectionalIterator (const unique_ptr< IRep > &rep) noexcept
 This overload is usually not called directly. Instead, iterators are usually created from a container (eg. Sequence<T>{}.begin()).
 
nonvirtual BidirectionalIteratoroperator= (BidirectionalIterator &&rhs) noexcept=default
 Iterators are safely copyable, preserving their current position.
 
nonvirtual BidirectionalIteratoroperator++ ()
 same as Iterator::operator++ () - advances iterator - but returns the subclass iterator type.
 
nonvirtual BidirectionalIteratoroperator-- ()
 
nonvirtual BidirectionalIterator operator- (ptrdiff_t i) const
 Move the iterator back by the specified number of positions.
 
nonvirtual IRepGetRep ()
 Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.
 
nonvirtual const IRepConstGetRep () const
 Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.
 
- Public Member Functions inherited from Stroika::Foundation::Traversal::Iterator< T, ITERATOR_TRAITS >
 Iterator (const unique_ptr< IRep > &rep) noexcept
 This overload is usually not called directly. Instead, iterators are usually created from a container (eg. Sequence<T>{}.begin()).
 
nonvirtual Iteratoroperator= (Iterator &&rhs) noexcept
 Iterators are safely copyable, preserving their current position. Copy-Assigning could throw since it probably involves a Clone()
 
nonvirtual const T & operator* () const
 Return the Current value pointed to by the Iterator<T> (same as Current())
 
nonvirtual const value_typeoperator-> () const
 Return a pointer to the current value pointed to by the Iterator<T> (like Current())
 
nonvirtual Iteratoroperator++ ()
 Advance iterator; support for range-based-for, and STL style iteration in general (containers must also support begin, end).
 
nonvirtual Iterator operator+ (ptrdiff_t i) const
 
nonvirtual operator bool () const
 return not AtEnd ()
 
nonvirtual bool operator== (const Iterator &rhs) const
 Equals () checks if two iterators are equal to one another (point to the same position in the sequence).
 
nonvirtual const T & Current () const
 Returns the value of the current item visited by the Iterator<T>, and is illegal to call if AtEnd()
 
nonvirtual bool AtEnd () const
 AtEnd () means there is nothing left in this iterator (a synonym for (it == container.end ()).
 
nonvirtual void reset ()
 Set to AtEnd and disassociate with owner.
 
nonvirtual void clear ()
 Set to AtEnd and disassociate with owner.
 
nonvirtual IRepGetRep ()
 Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.
 
nonvirtual const IRepConstGetRep () const
 Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.
 
nonvirtual void Refresh ()
 Refresh the current iterator state based on what is in the underlying IRep.
 
nonvirtual void Invariant () const noexcept
 Invariant does nothing if !qStroika_Foundation_Debug_AssertionsChecked, but if qStroika_Foundation_Debug_AssertionsChecked, checks internal state and asserts in good shape.
 

Additional Inherited Members

- Static Public Member Functions inherited from Stroika::Foundation::Traversal::Iterator< T, ITERATOR_TRAITS >
static constexpr default_sentinel_t GetEmptyIterator () noexcept
 Used by someContainer::end ()
 

Detailed Description

template<typename T, typename ITERATOR_TRAITS = Support::DefaultIteratorTraits<T>>
class Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >

A BidirectionalIterator is an Iterator that can be moved both forward and backward.

BidirectionalIterator allows backing up (if not AtStart), and then moving forward again (if not AtEnd - like the base class Iterator).

Note
Satisfies Concepts: o regular<BidirectionalIterator<T>> // implies copyable/movable/equality_comparable o bidirectional_iterator<BidirectionalIterator<T>> o sentinel_for<default_sentinel_t, BidirectionalIterator<T>> o constructible_from<Iterator<T>, BidirectionalIterator<T>>

Definition at line 34 of file BidirectionalIterator.h.

Member Typedef Documentation

◆ iterator_category

template<typename T , typename ITERATOR_TRAITS = Support::DefaultIteratorTraits<T>>
using Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::iterator_category = bidirectional_iterator_tag
Note
this is used by the concept bidirectional_iterator.

Definition at line 54 of file BidirectionalIterator.h.

Constructor & Destructor Documentation

◆ BidirectionalIterator()

template<typename T , typename ITERATOR_TRAITS >
Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::BidirectionalIterator ( const unique_ptr< IRep > &  rep)
noexcept

This overload is usually not called directly. Instead, iterators are usually created from a container (eg. Sequence<T>{}.begin()).

Iterators are safely copyable, preserving their current position.

CTOR overload taking nullptr - is the same as GetEmptyIterator ()

Note
default construction of BidirectionalIterator means empty (both at start and end).
Precondition
RequireNotNull (rep.get ()) for rep-taking CTOR
Note
constructor with argument default_sentinel_t - creates an end iterator

Definition at line 14 of file BidirectionalIterator.inl.

Member Function Documentation

◆ operator++()

template<typename T , typename ITERATOR_TRAITS >
auto Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::operator++ ( )

same as Iterator::operator++ () - advances iterator - but returns the subclass iterator type.

The subclass impl is functionaly identical, but hiding the base class implementation needed to satisfy the concepts for bidirectional iterators.

Definition at line 44 of file BidirectionalIterator.inl.

◆ operator--()

template<typename T , typename ITERATOR_TRAITS >
auto Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::operator-- ( )
Precondition
not AtStart ()

Definition at line 57 of file BidirectionalIterator.inl.

◆ operator-()

template<typename T , typename ITERATOR_TRAITS >
auto Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::operator- ( ptrdiff_t  i) const

Move the iterator back by the specified number of positions.

Precondition
i >= 0

Definition at line 71 of file BidirectionalIterator.inl.

◆ GetRep()

template<typename T , typename ITERATOR_TRAITS >
BidirectionalIterator< T, ITERATOR_TRAITS >::IRep & Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::GetRep ( )

Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.

Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.

Definition at line 81 of file BidirectionalIterator.inl.

◆ ConstGetRep()

template<typename T , typename ITERATOR_TRAITS >
const BidirectionalIterator< T, ITERATOR_TRAITS >::IRep & Stroika::Foundation::Traversal::BidirectionalIterator< T, ITERATOR_TRAITS >::ConstGetRep ( ) const

Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.

Get a reference to the IRep owned by the iterator. This is an implementation detail, mainly intended for implementors.

Definition at line 86 of file BidirectionalIterator.inl.


The documentation for this class was generated from the following files: