22#include "bits/list_basics.h"
29 S_list_item() : _n(0) {}
31 explicit S_list_item(
bool) {}
34 template<
typename T,
typename P>
friend class S_list;
35 template<
typename T,
typename P>
friend class S_list_tail;
36 template<
typename T,
typename X>
friend struct Bits::Basic_list_policy;
38 S_list_item(S_list_item
const &);
39 void operator = (S_list_item
const &);
50template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
54 void operator = (
S_list const &) =
delete;
60 typedef typename Base::Iterator Iterator;
66 Base::operator = (
static_cast<Base&&
>(o));
82 template<
typename CAS >
83 void add(T *e, CAS
const &c)
89 while (!c(&this->
_f, e->_n, e));
102 T *r = this->
front();
104 this->
_f = this->
_f->_n;
108 void insert(T *e, Iterator
const &pred)
110 S_list_item *p = *pred;
115 static void insert_before(T *e, Iterator
const &succ)
117 S_list_item **x = Base::__get_internal(succ);
123 static void replace(Iterator
const &p, T*e)
125 S_list_item **x = Base::__get_internal(p);
130 static Iterator erase(Iterator
const &e)
132 S_list_item **x = Base::__get_internal(e);
140template<
typename T >
141class S_list_bss :
public S_list<T>
144 S_list_bss() : S_list<T>(true) {}
147template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
148class S_list_tail :
public S_list<T, POLICY>
151 typedef S_list<T, POLICY> Base;
152 void add(T *e) =
delete;
155 using Iterator =
typename Base::Iterator;
156 S_list_tail() : Base(), _tail(&this->
_f) {}
158 S_list_tail(S_list_tail &&t)
159 : Base(static_cast<Base&&>(t)), _tail(t.
empty() ? &this->
_f : t._tail)
164 S_list_tail &operator = (S_list_tail &&t)
169 Base::operator = (
static_cast<Base &&
>(t));
170 _tail = t.empty() ? &this->
_f : t._tail;
175 void push_front(T *e)
196 void append(S_list_tail &o)
214 static void insert(T *e, Iterator
const &pred);
215 static void insert_before(T *e, Iterator
const &succ);
216 static void replace(Iterator
const &p, T*e);
217 static Iterator erase(Iterator
const &e);
Internal: Common functions for all head-based list implementations.
bool empty() const
Check if the list is empty.
void clear()
Remove all elements from the list.
POLICY::Head_type _f
Pointer to front of the list.
Value_type front() const
Return the first element in 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.