1#ifndef INCLUDES_MYSQL_SQL_LIST_H
2#define INCLUDES_MYSQL_SQL_LIST_H
113 assert(
this != tail);
119 for (uint i = 0; i < sz; i++) {
275 if (!
list->is_empty()) {
293 while (node && node != list_first) {
302 if (!
list->is_empty()) {
331#ifdef LIST_EXTRA_DEBUG
347 bool check_list(
const char *
name) {
355 (
"%s: error: NULL element in the list",
name));
362 DBUG_PRINT(
"list_invariants", (
"%s: error: wrong last pointer",
name));
366 DBUG_PRINT(
"list_invariants", (
"%s: error: wrong element count",
name));
377 node->
next = new_node;
383 if (!new_node)
return true;
385 node->
next = new_node;
395 void *
at(uint index);
532 next = element->
next;
533 delete (T *)element->
info;
541 next = element->
next;
550 for (uint i = 0; i < index; ++i) current = current->
next;
551 return static_cast<T *
>(current->
info);
557 for (uint i = 0; i < index; ++i) current = current->
next;
558 current->
info = new_value;
562 if (index1 == index2)
return false;
566 if (index2 < index1)
std::swap(index1, index2);
569 for (uint i = 0; i < index1; ++i) current1 = current1->
next;
572 for (uint i = 0; i < index2 - index1; ++i) current2 = current2->
next;
593 template <
typename Node_cmp_func>
598 if (
cmp(
static_cast<T *
>(n1->info),
static_cast<T *
>(n2->info)) > 0) {
599 void *tmp = n1->info;
648 return const_cast<T **
>(
660 inline T **
ref(
void) {
return (T **)0; }
705 return !(*
this == other);
772 :
key(key_arg),
val(val_arg) {}
783 static_assert(!std::is_polymorphic<T>::value,
784 "Do not use this for classes with virtual members");
801 first->prev = &a->next;
810 a->next =
static_cast<T *
>(&
sentinel);
818 T *first_link =
first;
819 first_link->unlink();
864 if (
current ==
static_cast<T *
>(&
list->sentinel))
return nullptr;
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: sql_list.h:886
I_List_iterator(I_List< T > &a)
Definition: sql_list.h:888
T * operator++(int)
Definition: sql_list.h:889
Definition: sql_list.h:871
void move_elements_to(I_List< T > *new_owner)
Definition: sql_list.h:879
Definition: sql_list.h:680
T & operator*() const
Definition: sql_list.h:685
T * operator->() const
Definition: sql_list.h:708
T value_type
Definition: sql_list.h:693
bool operator==(const List_STL_Iterator &other) const
Definition: sql_list.h:699
List_STL_Iterator()=default
std::forward_iterator_tag iterator_category
Definition: sql_list.h:696
list_node * m_current
Definition: sql_list.h:721
T * pointer
Definition: sql_list.h:694
List_STL_Iterator(list_node *node)
Definition: sql_list.h:682
T & reference
Definition: sql_list.h:695
List_STL_Iterator & operator++()
Definition: sql_list.h:687
List_STL_Iterator operator++(int)
Definition: sql_list.h:714
bool operator!=(const List_STL_Iterator &other) const
Definition: sql_list.h:704
ptrdiff_t difference_type
Definition: sql_list.h:692
Definition: sql_list.h:654
T * replace(T *)
Definition: sql_list.h:656
List_iterator_fast(List< T > &a)
Definition: sql_list.h:663
void after(T *)
Definition: sql_list.h:659
void remove(void)
Definition: sql_list.h:658
T ** ref(void)
Definition: sql_list.h:660
void sublist(List< T > &list_arg, uint el_arg)
Definition: sql_list.h:668
void init(List< T > &a)
Definition: sql_list.h:665
void rewind(void)
Definition: sql_list.h:667
T * operator++(int)
Definition: sql_list.h:666
T * replace(List< T > &)
Definition: sql_list.h:657
List_iterator_fast()
Definition: sql_list.h:664
Definition: sql_list.h:633
List_iterator()
Definition: sql_list.h:636
void init(List< T > &a)
Definition: sql_list.h:637
T ** ref(void)
Definition: sql_list.h:647
void after(T *a)
Definition: sql_list.h:643
T * replace(List< T > &a)
Definition: sql_list.h:640
T * replace(T *a)
Definition: sql_list.h:639
T * operator++(int)
Definition: sql_list.h:638
bool after(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:644
void remove()
Definition: sql_list.h:642
void rewind(void)
Definition: sql_list.h:641
List_iterator(List< T > &a)
Definition: sql_list.h:635
Definition: sql_list.h:494
bool push_back(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:511
iterator begin()
Definition: sql_list.h:609
const_iterator begin() const
Definition: sql_list.h:620
const_iterator cend() const
Definition: sql_list.h:626
void delete_elements(void)
Definition: sql_list.h:529
const T * head() const
Definition: sql_list.h:521
List_STL_Iterator< const T > const_iterator
Definition: sql_list.h:619
void destroy_elements(void)
Definition: sql_list.h:538
List()
Definition: sql_list.h:496
List(const List< T > &tmp, MEM_ROOT *mem_root)
Definition: sql_list.h:501
void sort(Node_cmp_func cmp)
Sort the list.
Definition: sql_list.h:594
bool swap_elts(uint index1, uint index2)
Definition: sql_list.h:561
T * head()
Definition: sql_list.h:520
void disjoin(List< T > *list)
Definition: sql_list.h:527
bool push_back(T *a)
Definition: sql_list.h:508
List_STL_Iterator< T > iterator
Definition: sql_list.h:608
const_iterator end() const
Definition: sql_list.h:621
bool push_front(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:517
List(const List< T > &tmp)
Definition: sql_list.h:497
List & operator=(const List &tmp)
Definition: sql_list.h:498
T ** head_ref()
Definition: sql_list.h:524
T * operator[](uint index) const
Definition: sql_list.h:547
const_iterator cbegin() const
Definition: sql_list.h:625
iterator end()
Definition: sql_list.h:610
void prepend(List< T > *list)
Definition: sql_list.h:528
T * pop()
Definition: sql_list.h:525
bool push_front(T *a)
Definition: sql_list.h:514
void replace(uint index, T *new_value)
Definition: sql_list.h:554
void concat(List< T > *list)
Definition: sql_list.h:526
Simple intrusive linked list.
Definition: sql_list.h:48
SQL_I_List & operator=(SQL_I_List &&that)
Definition: sql_list.h:144
void save_and_clear(SQL_I_List< T > *save)
Definition: sql_list.h:87
SQL_I_List & operator=(SQL_I_List &that)
Definition: sql_list.h:134
T * first
The first element in the list.
Definition: sql_list.h:52
void push_front(SQL_I_List< T > *save)
Definition: sql_list.h:89
void push_back(SQL_I_List< T > *save)
Definition: sql_list.h:96
void link_in_list(T *element, T **next_ptr)
Definition: sql_list.h:80
uint elements
Definition: sql_list.h:50
SQL_I_List()
Definition: sql_list.h:60
T ** next
A reference to the next element in the list.
Definition: sql_list.h:58
void split_after(uint sz, SQL_I_List< T > *tail)
Definition: sql_list.h:112
uint size() const
Definition: sql_list.h:132
void clear()
Definition: sql_list.h:74
SQL_I_List(const SQL_I_List &tmp)
Definition: sql_list.h:62
SQL_I_List(SQL_I_List &&that)
Definition: sql_list.h:67
Definition: sql_list.h:852
T * current
Definition: sql_list.h:854
T * next(void) SUPPRESS_UBSAN
Definition: sql_list.h:861
base_ilist_iterator(base_ilist< T > &list_par)
Definition: sql_list.h:857
base_ilist< T > * list
Definition: sql_list.h:853
T ** el
Definition: sql_list.h:854
Definition: sql_list.h:779
T * get()
Definition: sql_list.h:816
void operator=(const base_ilist &)
void move_elements_to(base_ilist *new_owner)
Moves list elements to new owner, and empties current owner (i.e.
Definition: sql_list.h:832
T * first
Definition: sql_list.h:780
bool is_empty() const SUPPRESS_UBSAN
Definition: sql_list.h:795
void clear() SUPPRESS_UBSAN
Definition: sql_list.h:788
T * head()
Definition: sql_list.h:823
base_ilist(const base_ilist &)
void push_front(T *a)
Pushes new element in front of list.
Definition: sql_list.h:800
void push_back(T *a)
Pushes new element to the end of the list, i.e. in front of the sentinel.
Definition: sql_list.h:808
ilink< T > sentinel
Definition: sql_list.h:781
base_ilist()
Definition: sql_list.h:792
Definition: sql_list.h:399
void init(base_list &list_par)
Definition: sql_list.h:415
list_node ** prev
Definition: sql_list.h:402
void * next_fast(void)
Definition: sql_list.h:428
void ** ref(void)
Definition: sql_list.h:472
bool is_last(void)
Definition: sql_list.h:476
bool is_before_first() const
Definition: sql_list.h:477
void after(void *element)
Definition: sql_list.h:459
list_node ** el
Definition: sql_list.h:402
void * replace(void *element)
Definition: sql_list.h:435
void sublist(base_list &ls, uint elm)
Definition: sql_list.h:403
base_list_iterator()
Definition: sql_list.h:410
friend class error_list_iterator
Definition: sql_list.h:487
base_list_iterator(base_list &list_par)
Definition: sql_list.h:413
void rewind(void)
Definition: sql_list.h:434
list_node * current
Definition: sql_list.h:402
base_list * list
Definition: sql_list.h:401
void remove(void)
Definition: sql_list.h:453
bool prepend(void *a, MEM_ROOT *mem_root)
Definition: sql_list.h:478
bool after(void *a, MEM_ROOT *mem_root)
Definition: sql_list.h:465
void * replace(base_list &new_list)
Definition: sql_list.h:441
void * next(void)
Definition: sql_list.h:422
Definition: sql_list.h:185
bool push_back(void *info)
Definition: sql_list.h:226
void ** head_ref()
Definition: sql_list.h:321
list_node * last_ref()
Definition: sql_list.h:325
void disjoin(base_list *list)
Definition: sql_list.h:288
base_list(const base_list &tmp)
This is a shallow copy constructor that implicitly passes the ownership from the source list to the n...
Definition: sql_list.h:211
void concat(base_list *list)
Definition: sql_list.h:274
friend class error_list
Definition: sql_list.h:328
list_node * first_node()
Definition: sql_list.h:318
bool push_front(void *info)
Definition: sql_list.h:244
void * pop(void)
Definition: sql_list.h:281
uint size() const
Definition: sql_list.h:326
base_list()
Definition: sql_list.h:201
void swap(base_list &rhs)
Swap two lists.
Definition: sql_list.h:312
bool push_back(void *info, MEM_ROOT *mem_root)
Definition: sql_list.h:235
const void * head() const
Definition: sql_list.h:320
friend class error_list_iterator
Definition: sql_list.h:329
void after(void *info, list_node *node)
Definition: sql_list.h:375
list_node * last_node()
Definition: sql_list.h:317
bool is_empty() const
Definition: sql_list.h:324
void * head()
Definition: sql_list.h:319
bool operator==(const base_list &rhs) const
Definition: sql_list.h:192
void prepend(base_list *list)
Definition: sql_list.h:301
void remove(list_node **prev)
Definition: sql_list.h:265
uint elements
Definition: sql_list.h:190
list_node ** last
Definition: sql_list.h:187
base_list & operator=(const base_list &tmp)
Definition: sql_list.h:215
bool after(void *info, list_node *node, MEM_ROOT *mem_root)
Definition: sql_list.h:381
void clear()
Definition: sql_list.h:196
void * at(uint index)
For debugging purposes (e.g.
Definition: sql_list.cc:65
list_node * first
Definition: sql_list.h:187
bool push_front(void *info, MEM_ROOT *mem_root)
Definition: sql_list.h:254
Definition: sql_list.h:766
const char * val
Definition: sql_list.h:769
i_string_pair(const char *key_arg, const char *val_arg)
Definition: sql_list.h:771
i_string_pair()
Definition: sql_list.h:770
const char * key
Definition: sql_list.h:768
Definition: sql_list.h:758
i_string(const char *s)
Definition: sql_list.h:762
const char * ptr
Definition: sql_list.h:760
i_string()
Definition: sql_list.h:761
Definition: sql_list.h:738
T * next
Definition: sql_list.h:739
void unlink()
Definition: sql_list.h:744
T ** prev
Definition: sql_list.h:739
ilink()
Definition: sql_list.h:742
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1064
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
void destroy_at(T *ptr)
Definition: my_alloc.h:462
Header for compiler-dependent features.
#define SUPPRESS_UBSAN
Definition: my_compiler.h:120
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
Functions related to handling of plugins and other dynamically loaded libraries.
#define MYSQL_PLUGIN_IMPORT
Definition: my_sharedlib.h:71
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:354
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2880
MYSQL_PLUGIN_IMPORT list_node end_of_list
Definition: sql_list.cc:29
void free_list(I_List< i_string > *list)
Definition: sql_list.cc:31
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:663
case opt name
Definition: sslopt-case.h:29
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
list_node - a node of a single-linked list.
Definition: sql_list.h:171
list_node * next
Definition: sql_list.h:172
list_node()
Definition: sql_list.h:176
list_node(void *info_par, list_node *next_par)
Definition: sql_list.h:174
void * info
Definition: sql_list.h:173