126
120
relies on this behaviour. This logic is quite tricky: please do not use
127
121
it in any new code.
129
inline base_list(const base_list &tmp) :memory::SqlAlloc()
123
inline base_list(const base_list &tmp) :Sql_alloc()
131
125
elements= tmp.elements;
132
126
first= tmp.first;
133
127
last= elements ? tmp.last : &first;
130
Construct a deep copy of the argument in memory root mem_root.
131
The elements themselves are copied by pointer. If you also
132
need to copy elements by value, you should employ
133
list_copy_and_replace_each_value after creating a copy.
135
base_list(const base_list &rhs, MEM_ROOT *mem_root);
135
136
inline base_list(bool) { }
136
137
inline bool push_back(void *info)
387
388
inline List() :base_list() {}
388
389
inline List(const List<T> &tmp) :base_list(tmp) {}
389
inline List(const List<T> &tmp, memory::Root *mem_root) :
390
inline List(const List<T> &tmp, MEM_ROOT *mem_root) :
390
391
base_list(tmp, mem_root) {}
391
392
inline bool push_back(T *a) { return base_list::push_back(a); }
392
inline bool push_back(T *a, memory::Root *mem_root)
393
inline bool push_back(T *a, MEM_ROOT *mem_root)
393
394
{ return base_list::push_back(a, mem_root); }
394
395
inline bool push_front(T *a) { return base_list::push_front(a); }
395
396
inline T* head() {return (T*) base_list::head(); }
454
A simple intrusive list which automaticly removes element from list
455
on delete (for Session element)
460
struct ilink **prev,*next;
461
static void *operator new(size_t size)
463
return (void*)malloc((uint32_t)size);
465
static void operator delete(void* ptr_arg, size_t)
467
free((unsigned char*)ptr_arg);
476
/* Extra tests because element doesn't have to be linked */
477
if (prev) *prev= next;
478
if (next) next->prev=prev;
481
virtual ~ilink() { unlink(); } /*lint -e1740 */
485
/* Needed to be able to have an I_List of char* strings in mysqld.cc. */
487
class i_string: public ilink
491
i_string():ptr(0) { }
492
i_string(const char* s) : ptr(s) {}
495
/* needed for linked list of two strings for replicate-rewrite-db */
496
class i_string_pair: public ilink
501
i_string_pair():key(0),val(0) { }
502
i_string_pair(const char* key_arg, const char* val_arg) :
503
key(key_arg),val(val_arg) {}
507
template <class T> class I_List_iterator;
510
WARNING: copy constructor of this class does not create a usable
511
copy, as its members may point at each other.
517
struct ilink *first,last;
518
inline void empty() { first= &last; last.prev= &first; }
519
base_ilist() { empty(); }
520
inline bool is_empty() { return first == &last; }
521
inline void append(ilink *a)
523
first->prev= &a->next;
524
a->next=first; a->prev= &first; first=a;
526
inline void push_back(ilink *a)
533
inline struct ilink *get()
535
struct ilink *first_link=first;
536
if (first_link == &last)
538
first_link->unlink(); // Unlink from list
541
inline struct ilink *head()
543
return (first != &last) ? first : 0;
545
friend class base_list_iterator;
549
class base_ilist_iterator
552
struct ilink **el,*current;
554
base_ilist_iterator(base_ilist &list_par) :list(&list_par),
555
el(&list_par.first),current(0) {}
558
/* This is coded to allow push_back() while iterating */
560
if (current == &list->last) return 0;
568
class I_List :private base_ilist
571
I_List() :base_ilist() {}
572
inline void empty() { base_ilist::empty(); }
573
inline bool is_empty() { return base_ilist::is_empty(); }
574
inline void append(T* a) { base_ilist::append(a); }
575
inline void push_back(T* a) { base_ilist::push_back(a); }
576
inline T* get() { return (T*) base_ilist::get(); }
577
inline T* head() { return (T*) base_ilist::head(); }
579
friend class I_List_iterator<T>;
584
template <class T> class I_List_iterator :public base_ilist_iterator
587
I_List_iterator(I_List<T> &a) : base_ilist_iterator(a) {}
588
inline T* operator++(int) { return (T*) base_ilist_iterator::next(); }
453
592
Make a deep copy of each list element.