File SequenceRange.h

↰ Parent directory (ADS/sequence)

The range of the items of a SEQUENCE [see File 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 p = head(), read( p ), p = next( p ) until finished( p ) of the book.

Definition (ADS/sequence/SequenceRange.h)

Detailed Description

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 :math:` 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 File 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.

  1. Montresor, Algoritmi e Strutture Dati, 2025, section 3.2.1, https://algoritmicamente.it/materiali/libro/capitoli/cap03.pdf

  2. Stroustrup, The C++ Programming Language, 4th ed., Addison-Wesley, 2013, section 33.1 (the iterators)

Donato Meoli

Dipartimento di Informatica Universita’ di Pisa

by Donato Meoli

Includes

Namespaces

Classes

Functions