84#include <initializer_list>
140 [[nodiscard]]
bool empty(
void )
const {
return( f_n == 0 ); }
143 [[nodiscard]] std::size_t
size(
void )
const {
return( f_n ); }
146 [[nodiscard]] std::size_t
block(
void )
const {
return( f_b ); }
149 [[nodiscard]] std::size_t
blocks(
void )
const {
return( f_blocks ); }
154 return( f_blocks * f_cap );
167 [[nodiscard]]
const T &
front(
void )
const;
171 [[nodiscard]]
const T &
back(
void )
const;
198 void insert( std::size_t i ,
const T & x );
250 template<
bool Const >
253 using Owner = std::conditional_t< Const , const SEList , SEList >;
261 using reference = std::conditional_t< Const , const T & , T & >;
263 using pointer = std::conditional_t< Const , const T * , T * >;
270 : f_l( l ) , f_u( u ) , f_j( j ) { }
274 requires( Const && ! K )
276 : f_l( o.f_l ) , f_u( o.f_u ) , f_j( o.f_j ) { }
284 if( ++f_j == f_u->n ) {
313 return( ( f_u == o.f_u ) && ( f_j == o.f_j ) );
319 Owner * f_l =
nullptr;
320 Node * f_u =
nullptr;
329 return(
iterator(
this , f_dummy.next , 0 ) );
333 return(
iterator(
this , &f_dummy , 0 ) );
356 static constexpr std::size_t OFF =
357 (
sizeof( Node ) +
alignof( T ) - 1 ) /
alignof( T ) *
alignof( T );
359 static constexpr std::size_t ALIGN =
alignof( T ) >
alignof( Node )
364 T * places( Node * u )
const {
365 return(
reinterpret_cast< T *
>(
reinterpret_cast< unsigned char *
>( u ) +
371 std::size_t wrap( std::size_t i )
const {
372 return( i >= f_cap ? i - f_cap : i );
376 T & at( Node * u , std::size_t j )
const {
377 return( places( u )[ wrap( u->head + j ) ] );
382 Node * locate( std::size_t i , std::size_t & j )
const;
385 bool middle(
const Node * u )
const {
386 return( ( u->prev != &f_dummy ) && ( u->next != &f_dummy ) );
390 Node * newBlock( Node * p );
393 void dropBlock( Node * u );
396 void pushFront( Node * u , T && x );
399 void pushBack( Node * u , T && x );
402 T popFront( Node * u );
405 T popBack( Node * u );
409 void insert( Node * u , std::size_t j , T && x );
413 void erase( Node * u , std::size_t j );
430 void spread( Node * u );
448 void gather( Node * u );
452 [[nodiscard]]
bool bounded(
void )
const;
454 mutable Node f_dummy;
455 Node * f_spare =
nullptr;
457 std::size_t f_blocks = 0;
471#include "ADS/sequence/impl/SEList.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Iterator(const Iterator< K > &o)
the constant iterator from the mutable one
Definition SEList.h:275
std::conditional_t< Const, const T &, T & > reference
a reference to an item, constant if Const
Definition SEList.h:261
Iterator operator++(int)
to the next item, returning the iterator before the step
Definition SEList.h:300
reference operator*(void) const
the item
Definition SEList.h:279
std::conditional_t< Const, const T *, T * > pointer
a pointer to an item, constant if Const
Definition SEList.h:263
T value_type
the items
Definition SEList.h:258
Iterator(Owner *l, Node *u, std::size_t j)
on the item of the block of l
Definition SEList.h:269
Iterator & operator--(void)
to the previous item
Definition SEList.h:291
pointer operator->(void) const
the address of the item
Definition SEList.h:281
Iterator & operator++(void)
to the next item, the next block after the last one of a block
Definition SEList.h:283
bool operator==(const Iterator &o) const
equal on the same item
Definition SEList.h:312
std::bidirectional_iterator_tag iterator_category
bidirectional
Definition SEList.h:257
Iterator operator--(int)
to the previous item, returning the iterator before the step
Definition SEList.h:306
std::ptrdiff_t difference_type
the distances
Definition SEList.h:259
friend class Iterator
Definition SEList.h:318
Iterator(void)=default
an iterator on no list
SEList(std::initializer_list< T > l)
the items of l, in order, with blocks of items at most
void insert(std::size_t i, const T &x)
puts at the rank , in amortized time
SEList(const SEList &o)
a copy of o, with its
void erase(std::size_t i)
removes the item of rank , in amortized time
void clear(void)
removes all the items and frees the blocks
void swap(SEList &o) noexcept
exchanges the blocks with those of o
T & reference
a reference to an item
Definition SEList.h:114
SEList(SEList &&o) noexcept
the blocks of o, which is left empty
const T & back(void) const
the last item
bool empty(void) const
true if there is no item
Definition SEList.h:140
Iterator< true > const_iterator
on the constant items
Definition SEList.h:325
SEList & operator=(SEList o) noexcept
the items of o, by copy and swap
const T & const_reference
a constant reference
Definition SEList.h:115
const_iterator begin(void) const
the constant iterator on the first item
Definition SEList.h:336
iterator begin(void)
the iterator on the first item
Definition SEList.h:328
iterator end(void)
the iterator past the last item
Definition SEList.h:332
std::size_t block(void) const
the parameter
Definition SEList.h:146
void pop_back(void)
removes the last item,
std::ptrdiff_t difference_type
the type of the distances
Definition SEList.h:113
const T & front(void) const
the first item
bool operator==(const SEList &o) const
the same items in the same order
std::size_t blocks(void) const
the number of blocks
Definition SEList.h:149
std::size_t size_type
the type of the sizes
Definition SEList.h:112
T value_type
the type of the items
Definition SEList.h:111
void pop_front(void)
removes the first item,
void push_front(const T &x)
at the front,
const_iterator end(void) const
the constant iterator past the last item
Definition SEList.h:340
~SEList()
destroys the items and frees the blocks
std::size_t capacity(void) const
the places of the blocks, each, at most
Definition SEList.h:153
SEList(std::size_t b=63)
the empty list with blocks of items at most
void push_back(const T &x)
at the back,
Iterator< false > iterator
the iterator on the items
Definition SEList.h:324
std::size_t size(void) const
the number of items
Definition SEList.h:143
const T & operator[](std::size_t i) const
the item of rank , constant
T & operator[](std::size_t i)
the item of rank ,