36#ifndef __ADS_SequenceRange
37 #define __ADS_SequenceRange
64class SequenceRange :
public std::ranges::view_interface< SequenceRange< S > >
85 iterator(
const S * s ,
typename S::Pos p ) : f_s( s ) , f_p( p ) { }
97 return( f_s->read( f_p ) );
105 f_p = f_s->next( f_p );
117 [[nodiscard]]
bool operator==( std::default_sentinel_t )
const {
123 const bool a = atEnd() , b = o.atEnd();
124 return( ( a == b ) && ( a || ( f_p == o.f_p ) ) );
128 [[nodiscard]]
typename S::Pos
position(
void )
const {
return( f_p ); }
131 [[nodiscard]]
bool atEnd(
void )
const {
132 return( f_end || ( f_s ==
nullptr ) || f_s->finished( f_p ) );
135 const S * f_s =
nullptr;
136 typename S::Pos f_p{};
148 return(
iterator( f_s , f_s->head() ) );
158 const S * f_s =
nullptr;
163template< Sequence S >
173template< ADS::Sequence S >
175 std::ranges::enable_borrowed_range< ADS::SequenceRange< S > > =
true;
182#include "ADS/sequence/impl/SequenceRange.tpp"
The abstract data types of the book, as concepts of C++20: SEQUENCE, SET and DICTIONARY (chapter 3),...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a position of the sequence, read by *; the end is an iterator marked as such, equal to every iterator...
Definition SequenceRange.h:72
iterator operator++(int)
to the next position, returning the iterator before the step
Definition SequenceRange.h:110
iterator & operator++(void)
to the next position, next( p )
Definition SequenceRange.h:104
reference operator*(void) const
the item in the position, read( p )
Definition SequenceRange.h:96
std::ptrdiff_t difference_type
the type of the distances
Definition SequenceRange.h:77
S::Pos position(void) const
the position of the book
Definition SequenceRange.h:128
const value_type & reference
a constant reference
Definition SequenceRange.h:78
bool operator==(std::default_sentinel_t) const
at the end, i.e., on a finished position
Definition SequenceRange.h:117
const value_type * pointer
a constant pointer
Definition SequenceRange.h:79
bool operator==(const iterator &o) const
equal if both are at the end, or on the same position
Definition SequenceRange.h:122
typename S::Item value_type
the type of the items
Definition SequenceRange.h:76
pointer operator->(void) const
the address of the item in the position
Definition SequenceRange.h:101
iterator(void)=default
an iterator on no sequence, at the end
static iterator end(const S *s)
the end of the range of
Definition SequenceRange.h:88
std::forward_iterator_tag iterator_category
the category of the iterator, forward
Definition SequenceRange.h:75
iterator(const S *s, typename S::Pos p)
on the position of the sequence
Definition SequenceRange.h:85
the items of a SEQUENCE as a range of C++
Definition SequenceRange.h:65
iterator end(void) const
the end, an iterator, so that the range is common and the algorithms of C++17 and of Boost take it,...
Definition SequenceRange.h:154
SequenceRange(void)=default
the range of no sequence
iterator begin(void) const
the iterator on the first item, head()
Definition SequenceRange.h:147
SequenceRange(const S &s)
the range of the items of
Definition SequenceRange.h:144
SequenceRange< S > range(const S &s)
the range of the items of