11#include "bits/list_basics.h"
18 S_list_item() : _n(nullptr) {}
20 explicit S_list_item(
bool) {}
23 template<
typename T,
typename P>
friend class S_list;
24 template<
typename T,
typename P>
friend class S_list_tail;
25 template<
typename T,
typename X>
friend struct Bits::Basic_list_policy;
27 S_list_item(S_list_item
const &);
28 void operator = (S_list_item
const &);
39template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
42 S_list(S_list
const &) =
delete;
43 void operator = (S_list
const &) =
delete;
49 typedef typename Base::Iterator Iterator;
51 S_list(S_list &&o) : Base(
static_cast<Base&&
>(o)) {}
53 S_list &operator = (S_list &&o)
56 Base::operator = (
static_cast<Base&&
>(o));
62 explicit S_list(
bool x) : Base(x) {}
73 template<
typename CAS >
74 void add(T *e, CAS
const &c)
80 while (!c(&this->
_f, e->_n, e));
95 this->
_f = this->
_f->_n;
99 void insert(T *e, Iterator
const &pred)
101 S_list_item *p = *pred;
106 static void insert_before(T *e, Iterator
const &succ)
108 S_list_item **x = Base::__get_internal(succ);
114 static void replace(Iterator
const &p, T*e)
116 S_list_item **x = Base::__get_internal(p);
121 static Iterator erase(Iterator
const &e)
123 S_list_item **x = Base::__get_internal(e);
131template<
typename T >
132class S_list_bss :
public S_list<T>
135 S_list_bss() : S_list<T>(true) {}
138template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
139class S_list_tail :
public S_list<T, POLICY>
142 typedef S_list<T, POLICY> Base;
143 void add(T *e) =
delete;
146 using Iterator =
typename Base::Iterator;
147 S_list_tail() : Base(), _tail(&this->
_f) {}
149 S_list_tail(S_list_tail &&t)
150 : Base(static_cast<Base&&>(t)), _tail(Base::
empty() ? &this->
_f : t._tail)
155 S_list_tail &operator = (S_list_tail &&t)
159 Base::operator = (
static_cast<Base &&
>(t));
168 void push_front(T *e)
189 void append(S_list_tail &o)
207 static void insert(T *e, Iterator
const &pred);
208 static void insert_before(T *e, Iterator
const &succ);
209 static void replace(Iterator
const &p, T*e);
210 static Iterator erase(Iterator
const &e);
Internal: Common functions for all head-based list implementations.
POLICY::Head_type _f
Pointer to front of the list.
Simple single-linked list.
void add(T *e)
Add an element to the front of the list.
void push_front(T *e)
Add an element to the front of the list.
T * pop_front()
Remove and return the head element of the list.