1#ifndef INCLUDES_MYSQL_SQL_LIST_H
2#define INCLUDES_MYSQL_SQL_LIST_H
221 if (!
list->is_empty()) {
239 while (node && node != list_first) {
248 if (!
list->is_empty()) {
277#ifdef LIST_EXTRA_DEBUG
293 bool check_list(
const char *
name) {
301 (
"%s: error: NULL element in the list",
name));
308 DBUG_PRINT(
"list_invariants", (
"%s: error: wrong last pointer",
name));
312 DBUG_PRINT(
"list_invariants", (
"%s: error: wrong element count",
name));
323 node->
next = new_node;
329 if (!new_node)
return true;
331 node->
next = new_node;
472 next = element->
next;
473 delete (T *)element->
info;
481 next = element->
next;
490 for (
uint i = 0; i < index; ++i) current = current->
next;
491 return static_cast<T *
>(current->
info);
497 for (
uint i = 0; i < index; ++i) current = current->
next;
498 current->
info = new_value;
502 if (index1 == index2)
return false;
506 if (index2 < index1)
std::swap(index1, index2);
509 for (
uint i = 0; i < index1; ++i) current1 = current1->
next;
512 for (
uint i = 0; i < index2 - index1; ++i) current2 = current2->
next;
533 template <
typename Node_cmp_func>
538 if (
cmp(
static_cast<T *
>(n1->info),
static_cast<T *
>(n2->info)) > 0) {
539 void *tmp = n1->info;
588 return const_cast<T **
>(
600 inline T **
ref(
void) {
return (T **)0; }
645 return !(*
this == other);
712 :
key(key_arg),
val(val_arg) {}
723 static_assert(!std::is_polymorphic<T>::value,
724 "Do not use this for classes with virtual members");
741 first->prev = &a->next;
750 a->next =
static_cast<T *
>(&
sentinel);
758 T *first_link =
first;
759 first_link->unlink();
804 if (
current ==
static_cast<T *
>(&
list->sentinel))
return nullptr;
Definition: sql_list.h:826
I_List_iterator(I_List< T > &a)
Definition: sql_list.h:828
T * operator++(int)
Definition: sql_list.h:829
Definition: sql_list.h:811
void move_elements_to(I_List< T > *new_owner)
Definition: sql_list.h:819
Definition: sql_list.h:620
T & operator*() const
Definition: sql_list.h:625
T * operator->() const
Definition: sql_list.h:648
T value_type
Definition: sql_list.h:633
bool operator==(const List_STL_Iterator &other) const
Definition: sql_list.h:639
List_STL_Iterator()=default
std::forward_iterator_tag iterator_category
Definition: sql_list.h:636
list_node * m_current
Definition: sql_list.h:661
T * pointer
Definition: sql_list.h:634
List_STL_Iterator(list_node *node)
Definition: sql_list.h:622
T & reference
Definition: sql_list.h:635
List_STL_Iterator & operator++()
Definition: sql_list.h:627
List_STL_Iterator operator++(int)
Definition: sql_list.h:654
bool operator!=(const List_STL_Iterator &other) const
Definition: sql_list.h:644
ptrdiff_t difference_type
Definition: sql_list.h:632
Definition: sql_list.h:594
T * replace(T *)
Definition: sql_list.h:596
List_iterator_fast(List< T > &a)
Definition: sql_list.h:603
void after(T *)
Definition: sql_list.h:599
void remove(void)
Definition: sql_list.h:598
T ** ref(void)
Definition: sql_list.h:600
void sublist(List< T > &list_arg, uint el_arg)
Definition: sql_list.h:608
void init(List< T > &a)
Definition: sql_list.h:605
void rewind(void)
Definition: sql_list.h:607
T * operator++(int)
Definition: sql_list.h:606
T * replace(List< T > &)
Definition: sql_list.h:597
List_iterator_fast()
Definition: sql_list.h:604
Definition: sql_list.h:573
List_iterator()
Definition: sql_list.h:576
void init(List< T > &a)
Definition: sql_list.h:577
T ** ref(void)
Definition: sql_list.h:587
void after(T *a)
Definition: sql_list.h:583
T * replace(List< T > &a)
Definition: sql_list.h:580
T * replace(T *a)
Definition: sql_list.h:579
T * operator++(int)
Definition: sql_list.h:578
bool after(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:584
void remove()
Definition: sql_list.h:582
void rewind(void)
Definition: sql_list.h:581
List_iterator(List< T > &a)
Definition: sql_list.h:575
Definition: sql_list.h:434
bool push_back(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:451
iterator begin()
Definition: sql_list.h:549
const_iterator begin() const
Definition: sql_list.h:560
const_iterator cend() const
Definition: sql_list.h:566
void delete_elements(void)
Definition: sql_list.h:469
const T * head() const
Definition: sql_list.h:461
List_STL_Iterator< const T > const_iterator
Definition: sql_list.h:559
void destroy_elements(void)
Definition: sql_list.h:478
List()
Definition: sql_list.h:436
List(const List< T > &tmp, MEM_ROOT *mem_root)
Definition: sql_list.h:441
void sort(Node_cmp_func cmp)
Sort the list.
Definition: sql_list.h:534
bool swap_elts(uint index1, uint index2)
Definition: sql_list.h:501
T * head()
Definition: sql_list.h:460
void disjoin(List< T > *list)
Definition: sql_list.h:467
bool push_back(T *a)
Definition: sql_list.h:448
List_STL_Iterator< T > iterator
Definition: sql_list.h:548
const_iterator end() const
Definition: sql_list.h:561
bool push_front(T *a, MEM_ROOT *mem_root)
Definition: sql_list.h:457
List(const List< T > &tmp)
Definition: sql_list.h:437
List & operator=(const List &tmp)
Definition: sql_list.h:438
T ** head_ref()
Definition: sql_list.h:464
T * operator[](uint index) const
Definition: sql_list.h:487
const_iterator cbegin() const
Definition: sql_list.h:565
iterator end()
Definition: sql_list.h:550
void prepend(List< T > *list)
Definition: sql_list.h:468
T * pop()
Definition: sql_list.h:465
bool push_front(T *a)
Definition: sql_list.h:454
void replace(uint index, T *new_value)
Definition: sql_list.h:494
void concat(List< T > *list)
Definition: sql_list.h:466
Simple intrusive linked list.
Definition: sql_list.h:46
void save_and_clear(SQL_I_List< T > *save)
Definition: sql_list.h:76
T * first
The first element in the list.
Definition: sql_list.h:50
void push_front(SQL_I_List< T > *save)
Definition: sql_list.h:81
void push_back(SQL_I_List< T > *save)
Definition: sql_list.h:88
void link_in_list(T *element, T **next_ptr)
Definition: sql_list.h:69
uint elements
Definition: sql_list.h:48
SQL_I_List()
Definition: sql_list.h:54
T ** next
A reference to the next element in the list.
Definition: sql_list.h:52
SQL_I_List & operator=(SQL_I_List &)=default
uint size() const
Definition: sql_list.h:96
void clear()
Definition: sql_list.h:63
SQL_I_List(const SQL_I_List &tmp)
Definition: sql_list.h:56
SQL_I_List(SQL_I_List &&)=default
SQL_I_List & operator=(SQL_I_List &&)=default
Definition: sql_list.h:792
T * current
Definition: sql_list.h:794
T * next(void) SUPPRESS_UBSAN
Definition: sql_list.h:801
base_ilist_iterator(base_ilist< T > &list_par)
Definition: sql_list.h:797
base_ilist< T > * list
Definition: sql_list.h:793
T ** el
Definition: sql_list.h:794
Definition: sql_list.h:719
T * get()
Definition: sql_list.h:756
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:772
T * first
Definition: sql_list.h:720
bool is_empty() const SUPPRESS_UBSAN
Definition: sql_list.h:735
void clear() SUPPRESS_UBSAN
Definition: sql_list.h:728
T * head()
Definition: sql_list.h:763
base_ilist(const base_ilist &)
void push_front(T *a)
Pushes new element in front of list.
Definition: sql_list.h:740
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:748
ilink< T > sentinel
Definition: sql_list.h:721
base_ilist()
Definition: sql_list.h:732
Definition: sql_list.h:339
void init(base_list &list_par)
Definition: sql_list.h:355
list_node ** prev
Definition: sql_list.h:342
void * next_fast(void)
Definition: sql_list.h:368
void ** ref(void)
Definition: sql_list.h:412
bool is_last(void)
Definition: sql_list.h:416
bool is_before_first() const
Definition: sql_list.h:417
void after(void *element)
Definition: sql_list.h:399
list_node ** el
Definition: sql_list.h:342
void * replace(void *element)
Definition: sql_list.h:375
void sublist(base_list &ls, uint elm)
Definition: sql_list.h:343
base_list_iterator()
Definition: sql_list.h:350
friend class error_list_iterator
Definition: sql_list.h:427
base_list_iterator(base_list &list_par)
Definition: sql_list.h:353
void rewind(void)
Definition: sql_list.h:374
list_node * current
Definition: sql_list.h:342
base_list * list
Definition: sql_list.h:341
void remove(void)
Definition: sql_list.h:393
bool prepend(void *a, MEM_ROOT *mem_root)
Definition: sql_list.h:418
bool after(void *a, MEM_ROOT *mem_root)
Definition: sql_list.h:405
void * replace(base_list &new_list)
Definition: sql_list.h:381
void * next(void)
Definition: sql_list.h:362
Definition: sql_list.h:131
bool push_back(void *info)
Definition: sql_list.h:172
void ** head_ref()
Definition: sql_list.h:267
list_node * last_ref()
Definition: sql_list.h:271
void disjoin(base_list *list)
Definition: sql_list.h:234
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:157
void concat(base_list *list)
Definition: sql_list.h:220
friend class error_list
Definition: sql_list.h:274
list_node * first_node()
Definition: sql_list.h:264
bool push_front(void *info)
Definition: sql_list.h:190
void * pop(void)
Definition: sql_list.h:227
uint size() const
Definition: sql_list.h:272
base_list()
Definition: sql_list.h:147
void swap(base_list &rhs)
Swap two lists.
Definition: sql_list.h:258
bool push_back(void *info, MEM_ROOT *mem_root)
Definition: sql_list.h:181
const void * head() const
Definition: sql_list.h:266
friend class error_list_iterator
Definition: sql_list.h:275
void after(void *info, list_node *node)
Definition: sql_list.h:321
list_node * last_node()
Definition: sql_list.h:263
bool is_empty() const
Definition: sql_list.h:270
void * head()
Definition: sql_list.h:265
bool operator==(const base_list &rhs) const
Definition: sql_list.h:138
void prepend(base_list *list)
Definition: sql_list.h:247
void remove(list_node **prev)
Definition: sql_list.h:211
uint elements
Definition: sql_list.h:136
list_node ** last
Definition: sql_list.h:133
base_list & operator=(const base_list &tmp)
Definition: sql_list.h:161
bool after(void *info, list_node *node, MEM_ROOT *mem_root)
Definition: sql_list.h:327
void clear()
Definition: sql_list.h:142
list_node * first
Definition: sql_list.h:133
bool push_front(void *info, MEM_ROOT *mem_root)
Definition: sql_list.h:200
Definition: sql_list.h:706
const char * val
Definition: sql_list.h:709
i_string_pair(const char *key_arg, const char *val_arg)
Definition: sql_list.h:711
i_string_pair()
Definition: sql_list.h:710
const char * key
Definition: sql_list.h:708
Definition: sql_list.h:698
i_string(const char *s)
Definition: sql_list.h:702
const char * ptr
Definition: sql_list.h:700
i_string()
Definition: sql_list.h:701
Definition: sql_list.h:678
T * next
Definition: sql_list.h:679
void unlink()
Definition: sql_list.h:684
T ** prev
Definition: sql_list.h:679
ilink()
Definition: sql_list.h:682
static MEM_ROOT mem_root
Definition: client_plugin.cc:110
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1064
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Header for compiler-dependent features.
#define SUPPRESS_UBSAN
Definition: my_compiler.h:134
#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
static int destroy(mysql_cond_t *that, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:54
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
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:642
case opt name
Definition: sslopt-case.h:33
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:117
list_node * next
Definition: sql_list.h:118
list_node()
Definition: sql_list.h:122
list_node(void *info_par, list_node *next_par)
Definition: sql_list.h:120
void * info
Definition: sql_list.h:119
unsigned int uint
Definition: uca9-dump.cc:75