26 #include <drizzled/memory/sql_alloc.h>
49 void link_in_list(
unsigned char *element,
unsigned char **next_ptr)
65 elements+= save->elements;
73 elements+= save->elements;
99 :next(next_par),info(info_par)
117 void clear() { elements=0; first= &end_of_list; last=&first;}
130 elements= tmp.elements;
132 last= elements ? tmp.last : &first;
135 void push_back(
void *info)
137 *last =
new list_node(info, &end_of_list);
138 last= &(*last)->next;
141 void push_back(
void *info, memory::Root& mem)
143 *last =
new (mem) list_node(info, &end_of_list);
144 last= &(*last)->next;
147 void push_front(
void *info)
149 list_node *node=
new list_node(info,first);
155 void remove(list_node **prev)
157 list_node *node=(*prev)->next;
160 else if (last == &(*prev)->next)
165 void concat(base_list *list)
167 if (!list->is_empty())
171 elements+= list->elements;
176 if (first == &end_of_list)
return 0;
177 list_node *tmp=first;
183 void disjoin(base_list *list)
185 list_node **prev= &first;
186 list_node *node= first;
187 list_node *list_first= list->first;
189 while (node && node != list_first)
198 void prepand(base_list *list)
200 if (!list->is_empty())
204 elements+= list->elements;
212 std::swap(first, rhs.first);
213 std::swap(last, rhs.last);
214 std::swap(elements, rhs.elements);
216 bool is_empty() {
return first == &end_of_list ; }
217 friend class base_list_iterator;
219 #ifdef LIST_EXTRA_DEBUG
235 bool check_list(
const char *name)
237 list_node *node= first;
240 while (node->next != &end_of_list)
249 if (last != &(node->next))
253 if (cnt+1 != elements)
259 #endif // LIST_EXTRA_DEBUG
262 void after(
void *info,list_node *node)
264 list_node *new_node=
new list_node(info,node->next);
267 if (last == &(node->next))
268 last= &new_node->next;
279 void sublist(
base_list &ls, uint32_t elm)
const
286 :list(0), el(0), prev(0), current(0)
290 :list(&list_par), el(el0), prev(0), current(0)
296 void *ret_value=current->info;
297 if (!new_list.is_empty())
299 *new_list.last=current->next;
300 current->info=new_list.first->info;
301 current->next=new_list.first->next;
302 if (list->last == ¤t->next && new_list.elements > 1)
303 list->last= new_list.last;
304 list->elements+=new_list.elements-1;
314 void after(
void *element)
316 list->after(element,current);
317 current=current->next;
334 T& front() {
return *
static_cast<T*
>(first->info); }
335 T* pop() {
return static_cast<T*
>(base_list::pop()); }
336 void concat(
List<T> *list) { base_list::concat(list); }
337 void disjoin(
List<T> *list) { base_list::disjoin(list); }
338 void prepand(
List<T> *list) { base_list::prepand(list); }
339 void delete_elements()
342 for (element=first; element != &end_of_list; element=next)
345 delete (T*) element->info;
352 return iterator(*
this, &first);
360 void set_size(
size_t v)
371 T *operator++(
int) { prev=el; current= *el; el= ¤t->next;
return (T*)current->info; }
372 T *replace(T *a) { T* old = (T*) current->info; current->info= a;
return old; }
373 void replace(List<T> &a) { base_list_iterator::replace(a); }
374 T** ref() {
return (T**) ¤t->info; }
378 return *(T*)current->info;
383 return (T*)current->info;
void swap(base_list &rhs)
TODO: Rename this file - func.h is stupid.
Visibility Control Macros.
base_list(const base_list &tmp)