124
119
relies on this behaviour. This logic is quite tricky: please do not use
125
120
it in any new code.
127
inline base_list(const base_list &tmp) :memory::SqlAlloc()
122
inline base_list(const base_list &tmp) :Sql_alloc()
129
124
elements= tmp.elements;
130
125
first= tmp.first;
131
126
last= elements ? tmp.last : &first;
129
Construct a deep copy of the argument in memory root mem_root.
130
The elements themselves are copied by pointer. If you also
131
need to copy elements by value, you should employ
132
list_copy_and_replace_each_value after creating a copy.
134
base_list(const base_list &rhs, MEM_ROOT *mem_root);
133
135
inline base_list(bool) { }
134
136
inline bool push_back(void *info)
385
387
inline List() :base_list() {}
386
388
inline List(const List<T> &tmp) :base_list(tmp) {}
387
inline List(const List<T> &tmp, memory::Root *mem_root) :
389
inline List(const List<T> &tmp, MEM_ROOT *mem_root) :
388
390
base_list(tmp, mem_root) {}
389
391
inline bool push_back(T *a) { return base_list::push_back(a); }
390
inline bool push_back(T *a, memory::Root *mem_root)
392
inline bool push_back(T *a, MEM_ROOT *mem_root)
391
393
{ return base_list::push_back(a, mem_root); }
392
394
inline bool push_front(T *a) { return base_list::push_front(a); }
393
395
inline T* head() {return (T*) base_list::head(); }
453
A simple intrusive list which automaticly removes element from list
454
on delete (for Session element)
459
struct ilink **prev,*next;
460
static void *operator new(size_t size)
462
return (void*)malloc((uint)size);
464
static void operator delete(void* ptr_arg, size_t)
466
free((unsigned char*)ptr_arg);
475
/* Extra tests because element doesn't have to be linked */
476
if (prev) *prev= next;
477
if (next) next->prev=prev;
480
virtual ~ilink() { unlink(); } /*lint -e1740 */
484
/* Needed to be able to have an I_List of char* strings in mysqld.cc. */
486
class i_string: public ilink
490
i_string():ptr(0) { }
491
i_string(const char* s) : ptr(s) {}
494
/* needed for linked list of two strings for replicate-rewrite-db */
495
class i_string_pair: public ilink
500
i_string_pair():key(0),val(0) { }
501
i_string_pair(const char* key_arg, const char* val_arg) :
502
key(key_arg),val(val_arg) {}
506
template <class T> class I_List_iterator;
509
WARNING: copy constructor of this class does not create a usable
510
copy, as its members may point at each other.
516
struct ilink *first,last;
517
inline void empty() { first= &last; last.prev= &first; }
518
base_ilist() { empty(); }
519
inline bool is_empty() { return first == &last; }
520
inline void append(ilink *a)
522
first->prev= &a->next;
523
a->next=first; a->prev= &first; first=a;
525
inline void push_back(ilink *a)
532
inline struct ilink *get()
534
struct ilink *first_link=first;
535
if (first_link == &last)
537
first_link->unlink(); // Unlink from list
540
inline struct ilink *head()
542
return (first != &last) ? first : 0;
544
friend class base_list_iterator;
548
class base_ilist_iterator
551
struct ilink **el,*current;
553
base_ilist_iterator(base_ilist &list_par) :list(&list_par),
554
el(&list_par.first),current(0) {}
557
/* This is coded to allow push_back() while iterating */
559
if (current == &list->last) return 0;
567
class I_List :private base_ilist
570
I_List() :base_ilist() {}
571
inline void empty() { base_ilist::empty(); }
572
inline bool is_empty() { return base_ilist::is_empty(); }
573
inline void append(T* a) { base_ilist::append(a); }
574
inline void push_back(T* a) { base_ilist::push_back(a); }
575
inline T* get() { return (T*) base_ilist::get(); }
576
inline T* head() { return (T*) base_ilist::head(); }
578
friend class I_List_iterator<T>;
583
template <class T> class I_List_iterator :public base_ilist_iterator
586
I_List_iterator(I_List<T> &a) : base_ilist_iterator(a) {}
587
inline T* operator++(int) { return (T*) base_ilist_iterator::next(); }
451
591
Make a deep copy of each list element.