19 #include <my_global.h>
21 template <
typename T,
typename L>
64 template <
typename T,
typename B,
77 I_P_List() : I(&m_first), m_first(NULL) {};
78 inline void empty() { m_first= NULL; C::reset(); I::set_last(&m_first); }
79 inline bool is_empty()
const {
return (m_first == NULL); }
80 inline void push_front(T* a)
82 *B::next_ptr(a)= m_first;
84 *B::prev_ptr(m_first)= B::next_ptr(a);
86 I::set_last(B::next_ptr(a));
88 *B::prev_ptr(a)= &m_first;
91 inline void push_back(T *a)
93 T **last= I::get_last();
94 *B::next_ptr(a)= *last;
96 *B::prev_ptr(a)= last;
97 I::set_last(B::next_ptr(a));
100 inline void insert_after(T *pos, T *a)
106 *B::next_ptr(a)= *B::next_ptr(pos);
107 *B::prev_ptr(a)= B::next_ptr(pos);
108 *B::next_ptr(pos)= a;
111 T *old_next= *B::next_ptr(a);
112 *B::prev_ptr(old_next)= B::next_ptr(a);
115 I::set_last(B::next_ptr(a));
119 inline void remove(T *a)
121 T *next= *B::next_ptr(a);
123 *B::prev_ptr(next)= *B::prev_ptr(a);
125 I::set_last(*B::prev_ptr(a));
126 **B::prev_ptr(a)= next;
129 inline T* front() {
return m_first; }
130 inline const T *front()
const {
return m_first; }
131 inline T* pop_front()
142 swap_variables(T *, m_first, rhs.m_first);
145 *B::prev_ptr(m_first)= &m_first;
147 I::set_last(&m_first);
149 *B::prev_ptr(rhs.m_first)= &rhs.m_first;
151 I::set_last(&rhs.m_first);
169 template <
typename T,
typename L>
176 : list(&a), current(a.m_first) {}
178 : list(&a), current(current_arg) {}
179 inline void init(
const L &a)
184 inline T* operator++(
int)
188 current= *L::Adapter::next_ptr(current);
191 inline T* operator++()
193 current= *L::Adapter::next_ptr(current);
198 current= list->m_first;
208 template <
typename T, T* T::*next, T** T::*prev>
211 static inline T **next_ptr(T *el) {
return &(el->*next); }
212 static inline const T*
const* next_ptr(
const T *el) {
return &(el->*next); }
213 static inline T ***prev_ptr(T *el) {
return &(el->*prev); }
242 void reset() {m_counter= 0;}
243 void inc() {m_counter++;}
244 void dec() {m_counter--;}
246 { swap_variables(uint, m_counter, rhs.m_counter); }
248 uint elements()
const {
return m_counter; }
261 void set_last(T **a) {}
281 void set_last(T **a) { m_last= a; }
282 T** get_last()
const {
return m_last; }
284 { swap_variables(T**, m_last, rhs.m_last); }