47#ifndef __ADS_CursorList
48 #define __ADS_CursorList
58#include <initializer_list>
142 [[nodiscard]]
long used(
void )
const;
148 [[nodiscard]]
bool partition(
void )
const;
150 std::vector< Cell > f_A;
199 [[nodiscard]]
bool empty(
void )
const;
274 [[nodiscard]]
long first(
void )
const;
283 template<
bool Const >
295 using reference = std::conditional_t< Const , const T & , T & >;
297 using pointer = std::conditional_t< Const , const T * , T * >;
304 Iterator( Space * S ,
long c ) : f_S( S ) , f_c( c ) { }
308 requires( Const && ! C )
317 f_c = ( *f_S )[ f_c ].next;
330 Space * f_S =
nullptr;
354 return(
iterator( f_S.get() , f_first ) );
372 template< std::input_iterator I , std::sentinel_for< I > S >
381 [[nodiscard]]
long & link(
Pos p );
384 [[nodiscard]]
long cell(
Pos p )
const;
386 std::shared_ptr< CursorSpace< T > > f_S;
399#include "ADS/sequence/impl/CursorList.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Iterator(const Iterator< C > &o)
the const iterator from the other one
Definition CursorList.h:309
pointer operator->(void) const
the address of the item
Definition CursorList.h:314
bool operator==(const Iterator &o) const =default
equal on the same cell of the same space
std::ptrdiff_t difference_type
the type of the distances
Definition CursorList.h:293
std::conditional_t< Const, const T *, T * > pointer
a pointer to an item, constant if Const
Definition CursorList.h:297
Iterator(Space *S, long c)
on the item of the cell of the space , the end if
Definition CursorList.h:304
Iterator(void)=default
an iterator on no space
std::forward_iterator_tag iterator_category
the category of the iterator, forward
Definition CursorList.h:291
reference operator*(void) const
the item
Definition CursorList.h:312
T value_type
the type of the items
Definition CursorList.h:292
std::conditional_t< Const, const T &, T & > reference
a reference to an item, constant if Const
Definition CursorList.h:295
friend class Iterator
Definition CursorList.h:334
Iterator & operator++(void)
to the next cell
Definition CursorList.h:316
Iterator operator++(int)
to the next cell, returning the iterator before the step
Definition CursorList.h:321
long Pos
the cursor of the cell before the item
Definition CursorList.h:168
CursorList(std::initializer_list< T > items)
the list of the given items, in a space of its own
CursorList(CursorList &&other) noexcept
the cells of other, which is left empty in the same space
Pos next(Pos p) const
the position that follows
std::ptrdiff_t difference_type
the type of the distances
Definition CursorList.h:342
std::size_t size_type
the type of the sizes
Definition CursorList.h:340
Pos insert(Pos p, const T &v)
puts in the position , the new item taking the position
T & reference
a reference to an item
Definition CursorList.h:344
long first(void) const
the cursor of the first cell, 0 if the list is empty
iterator begin(void)
the iterator on the first item
Definition CursorList.h:353
iterator end(void)
the iterator past the last item
Definition CursorList.h:357
T value_type
the type of the items
Definition CursorList.h:338
bool empty(void) const
true if there is no item
const_iterator cbegin(void) const
the constant iterator on the first item
Definition CursorList.h:367
CursorList(I first, S last)
the list of the items of [ first , last ), in their order
Iterator< false > iterator
the iterator on the items
Definition CursorList.h:348
Pos prev(Pos p) const
the position that precedes , , by a scan as in SinglyList::prev()
const CursorSpace< T > & space(void) const
the space of the list
Pos tail(void) const
the position of the last item, , by a scan as in SinglyList::tail()
const T & const_reference
a constant reference to an item
Definition CursorList.h:346
void swap(CursorList &other) noexcept
exchanges the cells, and the spaces, with other
void push_front(const T &v)
at the front, for std::front_inserter
Pos remove(Pos p)
removes the item in the position , whose successor takes the position
CursorList(void)
the empty list, in a space of its own
const T & read(Pos p) const
the item in the position
bool operator==(const CursorList &o) const
the same items in the same order
CursorList & operator=(CursorList other) noexcept
the items of other, by copy and swap
CursorList(const CursorList &other)
a copy of the items of other, in the same space
CursorList(std::shared_ptr< CursorSpace< T > > S)
the empty list in the space , shared with other lists
const_iterator begin(void) const
the constant iterator on the first item
Definition CursorList.h:359
const_iterator cend(void) const
the constant iterator past the last item
Definition CursorList.h:369
T Item
the type of the items
Definition CursorList.h:167
~CursorList()
gives the cells back to the free list of the space
bool finished(Pos p) const
true on and on
const_iterator end(void) const
the constant iterator past the last item
Definition CursorList.h:363
Iterator< true > const_iterator
the iterator on the constant items
Definition CursorList.h:350
Pos head(void) const
, i.e., 0
void write(Pos p, const T &v)
writes in the position
the vector of the cells of some CursorList, with its free list
Definition CursorList.h:79
CursorSpace(long dim=8)
a space of free cells, the places
void give(long c)
gives the cell back to the free list
const Cell & operator[](long c) const
the cell at the cursor , constant
long capacity(void) const
the number of places, 0 excluded
Cell & operator[](long c)
the cell at the cursor
long used(void) const
the number of cells in use
long take(void)
takes the first free cell, doubling the vector if there is none
a cell: the item and the cursor of the next cell, 0 for nil
Definition CursorList.h:85
T value
the item
Definition CursorList.h:86
long next
the cursor of the next cell, 0 for nil
Definition CursorList.h:87