22 #include "bits/list_basics.h" 23 #include "type_traits" 32 template<
typename ELEM_TYPE>
53 template<
typename T,
typename P>
friend class H_list;
54 template<
typename T,
typename X>
friend struct Bits::Basic_list_policy;
56 void l_remove() noexcept
78 template<
typename T,
typename POLICY = Bits::Basic_list_policy< T, H_list_item> >
82 typedef typename POLICY::Item_type Item;
85 void operator = (
H_list const &);
88 typedef typename Base::Iterator Iterator;
91 explicit H_list(
bool x) : Base(x) {}
103 static Iterator
iter(T *c) {
return Base::__iter(c->Item::_pn); }
106 static bool in_list(T
const *e) {
return e->Item::_pn; }
112 this->_f->_pn = &e->Item::_n;
113 e->Item::_n = this->_f;
114 e->Item::_pn = &this->_f;
115 this->_f =
static_cast<Item*
>(e);
128 T *r = this->front();
143 Iterator
insert(T *e, Iterator
const &pred)
145 Item **x = &this->_f;
146 if (pred != Base::end())
152 (*x)->_pn = &(e->Item::_n);
155 *x =
static_cast<Item*
>(e);
172 Item **x = &(*pred)->_n;
176 (*x)->_pn = &(e->Item::_n);
179 *x =
static_cast<Item*
>(e);
192 Item **x = Base::__get_internal(succ);
198 (*x)->_pn = &e->Item::_n;
200 *x =
static_cast<Item*
>(e);
214 e->Item::_n = p->Item::_n;
215 e->Item::_pn = p->Item::_pn;
216 *(p->Item::_pn) = static_cast<Item*>(e);
218 e->Item::_n->_pn = &(e->Item::_n);
228 static void remove(T *e)
229 { e->Item::l_remove(); }
244 static Iterator
erase(Iterator
const &e)
245 { e->Item::l_remove();
return e; }
255 template<
typename T >
264 template<
typename T >
265 class H_list_bss :
public H_list<T>
271 template<
typename T >
272 class H_list_t_bss :
public H_list_t<T>
General double-linked list of unspecified cxx::H_list_item elements.
static bool in_list(T const *e)
Check if the given element is currently part of a list.
static void replace(T *p, T *e)
Replace an element in a list with a new element.
Double-linked list of typed H_list_item_t elements.
Internal: Common functions for all head-based list implementations.
void add(T *e)
Add element to the front of the list.
static void insert_before(T *e, Iterator const &succ)
Insert an element before the iterator position.
static Iterator insert_after(T *e, Iterator const &pred)
Insert an element after the iterator position.
Iterator insert(T *e, Iterator const &pred)
Insert an element at the iterator position.
~H_list_item_t() noexcept
Destructor.
static Iterator erase(Iterator const &e)
Remove the element at the given iterator position.
static Iterator iter(T *c)
Return an iterator for an arbitrary list element.
Basic element type for a double-linked H_list.
T * pop_front()
Remove and return the head element of the list.
void push_front(T *e)
Add element to the front of the list.
H_list_item_t()
Constructor.