|
ADS
Algorithms and Data Structures
|
The range of the items of a SEQUENCE [see ADT.h], beyond the book, so that the for on a range of C++ visits a sequence through its positions: for( const auto & x : range( s ) ) is the loop of the book that sets \( p \) to head(), reads read( p ) and sets \( p \) to next( p ) until finished( p ). More...
#include "ADS/ADT.h"#include "ADS/Contract.h"#include <cstddef>#include <iterator>#include <ranges>#include "ADS/sequence/impl/SequenceRange.tpp"Go to the source code of this file.
Classes | |
| class | ADS::SequenceRange< S > |
| the items of a SEQUENCE as a range of C++ More... | |
| class | ADS::SequenceRange< S >::iterator |
| a position of the sequence, read by *; the end is an iterator marked as such, equal to every iterator on a finished position More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| template<Sequence S> | |
| SequenceRange< S > | ADS::range (const S &s) |
| the range of the items of \( s \) | |
The range of the items of a SEQUENCE [see ADT.h], beyond the book, so that the for on a range of C++ visits a sequence through its positions: for( const auto & x : range( s ) ) is the loop of the book that sets \( p \) to head(), reads read( p ) and sets \( p \) to next( p ) until finished( p ).
The iterator holds a position, and the end is an iterator marked as such that compares equal to any iterator on a finished position, so that no position \( \mathit{pos}_n \) needs to be computed (tail() costs \( O( n ) \) on a singly linked list) while the range stays common, as the algorithms of C++17 and of Boost want it; the range is a view, a pointer to the sequence. Each step costs what next() costs.
The contracts [see Contract.h] are those of the operations of the sequence; the sequence must not change while it is visited. The functions are defined in SequenceRange.tpp.