3 * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
10 * As a special exception, you may use this file as part of a free software
11 * library without restriction. Specifically, if other files instantiate
12 * templates or use macros or inline functions from this file, or you compile
13 * this file and link it with other files to produce an executable, this
14 * file does not by itself cause the resulting executable to be covered by
15 * the GNU General Public License. This exception does not however
16 * invalidate any other reasons why the executable file might be covered by
17 * the GNU General Public License.
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 &);
43 template< typename T, typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
44 class S_list : public Bits::Basic_list<POLICY>
46 S_list(S_list const &) = delete;
47 void operator = (S_list const &) = delete;
50 typedef typename Bits::Basic_list<POLICY> Base;
53 typedef typename Base::Iterator Iterator;
55 S_list(S_list &&o) : Base(static_cast<Base&&>(o)) {}
57 S_list &operator = (S_list &&o)
59 Base::operator = (static_cast<Base&&>(o));
64 explicit S_list(bool x) : Base(x) {}
74 template< typename CAS >
75 void add(T *e, CAS const &c)
81 while (!c(&this->_f, e->_n, e));
84 void push_front(T *e) { add(e); }
89 this->_f = this->_f->_n;
93 void insert(T *e, Iterator const &pred)
95 S_list_item *p = *pred;
100 static void insert_before(T *e, Iterator const &succ)
102 S_list_item **x = Base::__get_internal(succ);
108 static void replace(Iterator const &p, T*e)
110 S_list_item **x = Base::__get_internal(p);
115 static Iterator erase(Iterator const &e)
117 S_list_item **x = Base::__get_internal(e);
125 template< typename T >
126 class S_list_bss : public S_list<T>
129 S_list_bss() : S_list<T>(true) {}
132 template< typename T, typename POLICY = Bits::Basic_list_policy< T, S_list_item > >
133 class S_list_tail : public S_list<T, POLICY>
136 typedef S_list<T, POLICY> Base;
139 S_list_tail() : Base(), _tail(&this->_f) {}
141 S_list_tail(S_list_tail &&t) : Base(static_cast<Base&&>(t)), _tail(t._tail)
146 S_list_tail &operator = (S_list_tail &&t)
148 Base::operator = (static_cast<Base &&>(t));
167 void append(S_list_tail &o)