Template Class List

Nested Relationships

Nested Types

Class Documentation

template<class T, bool Pooled = true>
class List

a SEQUENCE realized as a bidirectional circular list with a sentinel, its cells from a pool if Pooled

Public Types

using Item = T

the type of the items

using Pos = Cell*

a position is the address of a cell

using value_type = T
using size_type = std::size_t
using difference_type = std::ptrdiff_t
using reference = T&
using const_reference = const T&
using iterator = Iterator<false>
using const_iterator = Iterator<true>
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>

Public Functions

List(void)

the empty list: the sentinel alone, its own predecessor and successor

List(std::initializer_list<T> items)

the list of the given items, in their order

template<std::input_iterator I, std::sentinel_for<I> S>
List(I first, S last)

the list of the items of [ first , last ), in their order

List(const List &other)
List(List &&other) noexcept

the cells of other, which is left empty, in O( 1 ) time

List &operator=(List other) noexcept
~List()
void swap(List &other) noexcept
bool empty(void) const

true if the list is empty, i.e., the sentinel is its own successor

bool finished(Pos p) const

true if p is \( pos_{-1} \) or \( pos_n \), i.e., the sentinel

Pos head(void) const

the position of the first item

Pos tail(void) const

the position of the last item

Pos next(Pos p) const

the position of the item that follows p

Pre:

p is a position of this list

Pos prev(Pos p) const

the position of the item that precedes p

Pre:

p is a position of this list

Pos insert(Pos p, const T &v)

puts v in position p, i.e., before the item in p, and returns its position

Pre:

p is a position of this list (an audit)

Post:

the list is not empty, the result precedes p and holds v

Pos remove(Pos p)

removes the item in position p, returning the position of its successor, which is now in its place

Pre:

p holds an item of this list (an audit)

Post:

the result follows the old predecessor of p

const T &read(Pos p) const

the item in position p

Pre:

p holds an item of this list

void write(Pos p, const T &v)

writes v in position p

Pre:

p holds an item of this list (an audit)

Post:

read( p ) is v

bool operator==(const List &o) const

the same items in the same order

inline iterator begin(void)
inline iterator end(void)
inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const
inline reverse_iterator rbegin(void)
inline reverse_iterator rend(void)
inline const_reverse_iterator rbegin(void) const
inline const_reverse_iterator rend(void) const
void push_back(const T &v)

v at the end and at the front, for the inserters of std

void push_front(const T &v)
struct Cell

a cell of the list: the sentinel is a Cell with no meaningful value

Public Members

Cell *pred

the predecessor

Cell *succ

the successor

T value

the item

template<bool Const>
class Iterator

the iterator, on items const if Const

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = T
using difference_type = std::ptrdiff_t
using reference = std::conditional_t<Const, const T&, T&>
using pointer = std::conditional_t<Const, const T*, T*>

Public Functions

Iterator(void) = default
inline explicit Iterator(Cell *c)
template<bool C>
inline Iterator(const Iterator<C> &o)

the const iterator from the other one

inline reference operator*(void) const
inline pointer operator->(void) const
inline Iterator &operator++(void)
inline Iterator operator++(int)
inline Iterator &operator--(void)
inline Iterator operator--(int)
bool operator==(const Iterator &o) const = default
inline Cell *cell(void) const

the cell, which is the position of the book