22#include "bits/list_basics.h"
29 S_list_item() : _n(0) {}
30 explicit S_list_item(
bool) {}
33 template<
typename T,
typename P>
friend class S_list;
34 template<
typename T,
typename P>
friend class S_list_tail;
35 template<
typename T,
typename X>
friend struct Bits::Basic_list_policy;
37 S_list_item(S_list_item
const &);
38 void operator = (S_list_item
const &);
49template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
53 void operator = (
S_list const &) =
delete;
59 typedef typename Base::Iterator Iterator;
65 Base::operator = (
static_cast<Base&&
>(o));
81 template<
typename CAS >
82 void add(T *e, CAS
const &c)
88 while (!c(&this->
_f, e->_n, e));
101 T *r = this->
front();
103 this->
_f = this->
_f->_n;
107 void insert(T *e, Iterator
const &pred)
109 S_list_item *p = *pred;
114 static void insert_before(T *e, Iterator
const &succ)
116 S_list_item **x = Base::__get_internal(succ);
122 static void replace(Iterator
const &p, T*e)
124 S_list_item **x = Base::__get_internal(p);
129 static Iterator erase(Iterator
const &e)
131 S_list_item **x = Base::__get_internal(e);
139template<
typename T >
140class S_list_bss :
public S_list<T>
143 S_list_bss() : S_list<T>(true) {}
146template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
147class S_list_tail :
public S_list<T, POLICY>
150 typedef S_list<T, POLICY> Base;
151 void add(T *e) =
delete;
154 using Iterator =
typename Base::Iterator;
155 S_list_tail() : Base(), _tail(&this->
_f) {}
157 S_list_tail(S_list_tail &&t)
158 : Base(static_cast<Base&&>(t)), _tail(t.
empty() ? &this->
_f : t._tail)
163 S_list_tail &operator = (S_list_tail &&t)
168 Base::operator = (
static_cast<Base &&
>(t));
169 _tail = t.empty() ? &this->
_f : t._tail;
174 void push_front(T *e)
195 void append(S_list_tail &o)
213 static void insert(T *e, Iterator
const &pred);
214 static void insert_before(T *e, Iterator
const &succ);
215 static void replace(Iterator
const &p, T*e);
216 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.