1#ifndef INCLUDES_MYSQL_SQL_LIST_H
2#define INCLUDES_MYSQL_SQL_LIST_H
110 assert(
this != tail);
116 for (uint i = 0; i < sz; i++) {
254 if (!
list->is_empty()) {
272 while (node && node != list_first) {
281 if (!
list->is_empty()) {
310#ifdef LIST_EXTRA_DEBUG
326 bool check_list(
const char *
name) {
334 (
"%s: error: NULL element in the list",
name));
341 DBUG_PRINT(
"list_invariants", (
"%s: error: wrong last pointer",
name));
345 DBUG_PRINT(
"list_invariants", (
"%s: error: wrong element count",
name));
356 node->
next = new_node;
362 if (!new_node)
return true;
364 node->
next = new_node;
505 next = element->
next;
506 delete (T *)element->
info;
514 next = element->
next;
523 for (uint i = 0; i < index; ++i) current = current->
next;
524 return static_cast<T *
>(current->
info);
530 for (uint i = 0; i < index; ++i) current = current->
next;
531 current->
info = new_value;
535 if (index1 == index2)
return false;
539 if (index2 < index1)
std::swap(index1, index2);
542 for (uint i = 0; i < index1; ++i) current1 = current1->
next;
545 for (uint i = 0; i < index2 - index1; ++i) current2 = current2->
next;
566 template <
typename Node_cmp_func>
571 if (
cmp(
static_cast<T *
>(n1->info),
static_cast<T *
>(n2->info)) > 0) {
572 void *tmp = n1->info;
621 return const_cast<T **
>(
633 inline T **
ref(
void) {
return (T **)0; }
678 return !(*
this == other);
745 :
key(key_arg),
val(val_arg) {}
756 static_assert(!std::is_polymorphic<T>::value,
757 "Do not use this for classes with virtual members");
774 first->prev = &a->next;
783 a->next =
static_cast<T *
>(&
sentinel);
791 T *first_link =
first;
792 first_link->unlink();
837 if (
current ==
static_cast<T *
>(&
list->sentinel))
return nullptr;
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: sql_list.h:859
I_List_iterator(I_List< T > &a)
Definition: sql_list.h:861
T * operator++(int)
Definition: sql_list.h:862
Definition: sql_list.h:844
void move_elements_to(I_List< T > *new_owner)
Definition: sql_list.h:852
Definition: sql_list.h:653
T & operator*() const
Definition: sql_list.h:658
T * operator->() const
Definition: sql_list.h:681
T value_type
Definition: sql_list.h:666
bool operator==(const List_STL_Iterator &other) const
Definition: sql_list.h:672
List_STL_Iterator()=default
std::forward_iterator_tag iterator_category
Definition: sql_list.h:669
list_node * m_current
Definition: sql_list.h:694
T * pointer
Definition: sql_list.h:667
List_STL_Iterator(list_node *node)
Definition: sql_list.h:655
T & reference
Definition: sql_list.h:668
List_STL_Iterator & operator++()
Definition: sql_list.h:660
List_STL_Iterator operator++(int)
Definition: sql_list.h:687
bool operator!=(const List_STL_Iterator &other) const
Definition: sql_list.h:677
ptrdiff_t difference_type
Definition: sql_list.h:665
Definition: sql_list.h:627
T * replace(T *)
Definition: sql_list.h:629
List_iterator_fast(List< T > &a)
Definition: sql_list.h:636
void after(T *)
Definition: sql_list.h:632
void remove(void)
Definition: sql_list.h:631
T ** ref(void)
Definition: sql_list.h:633
void sublist(List< T > &list_arg, uint el_arg)
Definition: sql_list.h:641
void init(List< T > &a)
Definition: sql_list.h:638
void rewind(void)
Definition: sql_list.h:640
T * operator++(int)
Definition: sql_list.h:639
T * replace(List< T > &)
Definition: sql_list.h:630
List_iterator_fast()
Definition: sql_list.h:637
Definition: sql_list.h:606
List_iterator()
Definition: sql_list.h:609
void init(List< T > &a)
Definition: sql_list.h:610
T ** ref(void)
Definition: sql_list.h:620
void after(T *a)
Definition: sql_list.h:616
T * replace(List< T > &a)
Definition: sql_list.h:613
T * replace(T *a)
Definition: sql_list.h:612
T * operator++(int)
Definition: sql_list.h:611
bool after(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:617
void remove()
Definition: sql_list.h:615
void rewind(void)
Definition: sql_list.h:614
List_iterator(List< T > &a)
Definition: sql_list.h:608
Definition: sql_list.h:467
bool push_back(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:484
iterator begin()
Definition: sql_list.h:582
const_iterator begin() const
Definition: sql_list.h:593
const_iterator cend() const
Definition: sql_list.h:599
void delete_elements(void)
Definition: sql_list.h:502
const T * head() const
Definition: sql_list.h:494
List_STL_Iterator< const T > const_iterator
Definition: sql_list.h:592
void destroy_elements(void)
Definition: sql_list.h:511
List()
Definition: sql_list.h:469
List(const List< T > &tmp, MEM_ROOT *mem_root)
Definition: sql_list.h:474
void sort(Node_cmp_func cmp)
Sort the list.
Definition: sql_list.h:567
bool swap_elts(uint index1, uint index2)
Definition: sql_list.h:534
T * head()
Definition: sql_list.h:493
void disjoin(List< T > *list)
Definition: sql_list.h:500
bool push_back(T *a)
Definition: sql_list.h:481
List_STL_Iterator< T > iterator
Definition: sql_list.h:581
const_iterator end() const
Definition: sql_list.h:594
bool push_front(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:490
List(const List< T > &tmp)
Definition: sql_list.h:470
List & operator=(const List &tmp)
Definition: sql_list.h:471
T ** head_ref()
Definition: sql_list.h:497
T * operator[](uint index) const
Definition: sql_list.h:520
const_iterator cbegin() const
Definition: sql_list.h:598
iterator end()
Definition: sql_list.h:583
void prepend(List< T > *list)
Definition: sql_list.h:501
T * pop()
Definition: sql_list.h:498
bool push_front(T *a)
Definition: sql_list.h:487
void replace(uint index, T *new_value)
Definition: sql_list.h:527
void concat(List< T > *list)
Definition: sql_list.h:499
Simple intrusive linked list.
Definition: sql_list.h:47
void save_and_clear(SQL_I_List< T > *save)
Definition: sql_list.h:81
T * first
The first element in the list.
Definition: sql_list.h:51
void push_front(SQL_I_List< T > *save)
Definition: sql_list.h:86
void push_back(SQL_I_List< T > *save)
Definition: sql_list.h:93
void link_in_list(T *element, T **next_ptr)
Definition: sql_list.h:74
uint elements
Definition: sql_list.h:49
SQL_I_List()
Definition: sql_list.h:59
T ** next
A reference to the next element in the list.
Definition: sql_list.h:57
void split_after(uint sz, SQL_I_List< T > *tail)
Definition: sql_list.h:109
SQL_I_List & operator=(SQL_I_List &)=default
uint size() const
Definition: sql_list.h:129
void clear()
Definition: sql_list.h:68
SQL_I_List(const SQL_I_List &tmp)
Definition: sql_list.h:61
SQL_I_List(SQL_I_List &&)=default
SQL_I_List & operator=(SQL_I_List &&)=default
Definition: sql_list.h:825
T * current
Definition: sql_list.h:827
T * next(void) SUPPRESS_UBSAN
Definition: sql_list.h:834
base_ilist_iterator(base_ilist< T > &list_par)
Definition: sql_list.h:830
base_ilist< T > * list
Definition: sql_list.h:826
T ** el
Definition: sql_list.h:827
Definition: sql_list.h:752
T * get()
Definition: sql_list.h:789
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:805
T * first
Definition: sql_list.h:753
bool is_empty() const SUPPRESS_UBSAN
Definition: sql_list.h:768
void clear() SUPPRESS_UBSAN
Definition: sql_list.h:761
T * head()
Definition: sql_list.h:796
base_ilist(const base_ilist &)
void push_front(T *a)
Pushes new element in front of list.
Definition: sql_list.h:773
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:781
ilink< T > sentinel
Definition: sql_list.h:754
base_ilist()
Definition: sql_list.h:765
Definition: sql_list.h:372
void init(base_list &list_par)
Definition: sql_list.h:388
list_node ** prev
Definition: sql_list.h:375
void * next_fast(void)
Definition: sql_list.h:401
void ** ref(void)
Definition: sql_list.h:445
bool is_last(void)
Definition: sql_list.h:449
bool is_before_first() const
Definition: sql_list.h:450
void after(void *element)
Definition: sql_list.h:432
list_node ** el
Definition: sql_list.h:375
void * replace(void *element)
Definition: sql_list.h:408
void sublist(base_list &ls, uint elm)
Definition: sql_list.h:376
base_list_iterator()
Definition: sql_list.h:383
friend class error_list_iterator
Definition: sql_list.h:460
base_list_iterator(base_list &list_par)
Definition: sql_list.h:386
void rewind(void)
Definition: sql_list.h:407
list_node * current
Definition: sql_list.h:375
base_list * list
Definition: sql_list.h:374
void remove(void)
Definition: sql_list.h:426
bool prepend(void *a, MEM_ROOT *mem_root)
Definition: sql_list.h:451
bool after(void *a, MEM_ROOT *mem_root)
Definition: sql_list.h:438
void * replace(base_list &new_list)
Definition: sql_list.h:414
void * next(void)
Definition: sql_list.h:395
Definition: sql_list.h:164
bool push_back(void *info)
Definition: sql_list.h:205
void ** head_ref()
Definition: sql_list.h:300
list_node * last_ref()
Definition: sql_list.h:304
void disjoin(base_list *list)
Definition: sql_list.h:267
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:190
void concat(base_list *list)
Definition: sql_list.h:253
friend class error_list
Definition: sql_list.h:307
list_node * first_node()
Definition: sql_list.h:297
bool push_front(void *info)
Definition: sql_list.h:223
void * pop(void)
Definition: sql_list.h:260
uint size() const
Definition: sql_list.h:305
base_list()
Definition: sql_list.h:180
void swap(base_list &rhs)
Swap two lists.
Definition: sql_list.h:291
bool push_back(void *info, MEM_ROOT *mem_root)
Definition: sql_list.h:214
const void * head() const
Definition: sql_list.h:299
friend class error_list_iterator
Definition: sql_list.h:308
void after(void *info, list_node *node)
Definition: sql_list.h:354
list_node * last_node()
Definition: sql_list.h:296
bool is_empty() const
Definition: sql_list.h:303
void * head()
Definition: sql_list.h:298
bool operator==(const base_list &rhs) const
Definition: sql_list.h:171
void prepend(base_list *list)
Definition: sql_list.h:280
void remove(list_node **prev)
Definition: sql_list.h:244
uint elements
Definition: sql_list.h:169
list_node ** last
Definition: sql_list.h:166
base_list & operator=(const base_list &tmp)
Definition: sql_list.h:194
bool after(void *info, list_node *node, MEM_ROOT *mem_root)
Definition: sql_list.h:360
void clear()
Definition: sql_list.h:175
list_node * first
Definition: sql_list.h:166
bool push_front(void *info, MEM_ROOT *mem_root)
Definition: sql_list.h:233
Definition: sql_list.h:739
const char * val
Definition: sql_list.h:742
i_string_pair(const char *key_arg, const char *val_arg)
Definition: sql_list.h:744
i_string_pair()
Definition: sql_list.h:743
const char * key
Definition: sql_list.h:741
Definition: sql_list.h:731
i_string(const char *s)
Definition: sql_list.h:735
const char * ptr
Definition: sql_list.h:733
i_string()
Definition: sql_list.h:734
Definition: sql_list.h:711
T * next
Definition: sql_list.h:712
void unlink()
Definition: sql_list.h:717
T ** prev
Definition: sql_list.h:712
ilink()
Definition: sql_list.h:715
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1057
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:459
Header for compiler-dependent features.
#define SUPPRESS_UBSAN
Definition: my_compiler.h:123
#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:2879
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:150
list_node * next
Definition: sql_list.h:151
list_node()
Definition: sql_list.h:155
list_node(void *info_par, list_node *next_par)
Definition: sql_list.h:153
void * info
Definition: sql_list.h:152