49template <
typename Type>
64#define UT_LIST_NODE_T(t) ut_list_node<t>
67#define UT_LIST_INITIALISED 0xCAFE
70#define UT_LIST_IS_INITIALISED(b) ((b).init == UT_LIST_INITIALISED)
80template <
typename Type,
typename NodeGetter>
85 return NodeGetter::get_node(e);
113 return count.load(std::memory_order_acquire);
141 template <
typename E>
152 return !(*
this == other);
244template <
typename Type, ut_list_node<Type> Type::*node_ptr>
247 return element.*node_ptr;
253#define UT_LIST_BASE_NODE_T(t, m) \
254 ut_list_base<t, ut_list_base_explicit_getter<t, &t::m>>
258#define UT_LIST_NODE_GETTER(t, m) t##_##m##_node_getter
270#define UT_LIST_NODE_GETTER_DEFINITION(t, m) \
271 struct UT_LIST_NODE_GETTER(t, m) \
272 : public ut_list_base_explicit_getter<t, &t::m> {};
279#define UT_LIST_BASE_NODE_T_EXTERN(t, m) \
280 ut_list_base<t, struct UT_LIST_NODE_GETTER(t, m)>
285#define UT_LIST_INIT(b) \
287 auto &list_ref = (b); \
288 new (&list_ref) std::remove_reference_t<decltype(list_ref)>(); \
294template <
typename List>
296 auto &elem_node = List::get_node(*elem);
300 elem_node.prev =
nullptr;
301 elem_node.next =
list.first_element;
303 if (
list.first_element !=
nullptr) {
306 List::get_node(*
list.first_element).prev = elem;
309 list.first_element = elem;
311 if (
list.last_element ==
nullptr) {
312 list.last_element = elem;
315 list.update_length(1);
321#define UT_LIST_ADD_FIRST(LIST, ELEM) ut_list_prepend(LIST, ELEM)
327template <
typename List>
329 auto &elem_node = List::get_node(*elem);
333 elem_node.next =
nullptr;
334 elem_node.prev =
list.last_element;
336 if (
list.last_element !=
nullptr) {
339 List::get_node(*
list.last_element).next = elem;
342 list.last_element = elem;
344 if (
list.first_element ==
nullptr) {
345 list.first_element = elem;
348 list.update_length(1);
354#define UT_LIST_ADD_LAST(LIST, ELEM) ut_list_append(LIST, ELEM)
360template <
typename List>
362 typename List::elem_type *elem2) {
363 ut_ad(elem1 != elem2);
364 ut_ad(elem1 !=
nullptr);
365 ut_ad(elem2 !=
nullptr);
368 auto &elem1_node = List::get_node(*elem1);
369 auto &elem2_node = List::get_node(*elem2);
371 elem2_node.prev = elem1;
372 elem2_node.next = elem1_node.next;
373 ut_ad((elem2_node.next ==
nullptr) == (
list.last_element == elem1));
374 if (elem2_node.next !=
nullptr) {
375 List::get_node(*elem2_node.next).prev = elem2;
377 list.last_element = elem2;
380 elem1_node.next = elem2;
382 list.update_length(1);
389#define UT_LIST_INSERT_AFTER(LIST, ELEM1, ELEM2) \
390 ut_list_insert(LIST, ELEM1, ELEM2)
396template <
typename List>
401 auto &node = List::get_node(*elem);
402 if (node.next !=
nullptr) {
403 List::get_node(*node.next).prev = node.prev;
405 list.last_element = node.prev;
408 if (node.prev !=
nullptr) {
409 List::get_node(*node.prev).next = node.next;
411 list.first_element = node.next;
417 list.update_length(-1);
423#define UT_LIST_REMOVE(LIST, ELEM) ut_list_remove(LIST, ELEM)
429#define UT_LIST_GET_NEXT(NAME, N) (((N)->NAME).next)
435#define UT_LIST_GET_PREV(NAME, N) (((N)->NAME).prev)
441#define UT_LIST_GET_LEN(BASE) (BASE).get_length()
446#define UT_LIST_GET_FIRST(BASE) (BASE).first_element
451#define UT_LIST_GET_LAST(BASE) (BASE).last_element
460template <
typename List,
class Functor>
466 for (
auto elem :
list) {
474template <
typename List>
478 for (
auto elem =
list.first_element; elem !=
nullptr;
479 elem = List::prev(*elem)) {
480 List::get_node(*elem).reverse();
486#define UT_LIST_REVERSE(LIST) ut_list_reverse(LIST)
492template <
typename List,
class Functor>
498 for (
auto elem =
list.last_element; elem !=
nullptr;
499 elem = List::prev(*elem)) {
508#define UT_LIST_CHECK(LIST) \
510 NullValidate nullV; \
511 ut_list_validate(LIST, nullV); \
518template <
typename List>
522 if (
list.first_element != elem) {
532template <
typename List>
535 for (
auto e1 :
list) {
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: sql_list.h:467
bool operator!=(const iterator &other) const
Definition: ut0lst.h:195
elem_type * m_elem
Definition: ut0lst.h:181
elem_type * operator*() const
Definition: ut0lst.h:196
bool operator==(const iterator &other) const
Definition: ut0lst.h:192
ut_list_base & m_list
Definition: ut0lst.h:180
iterator(ut_list_base &list, elem_type *elem)
Definition: ut0lst.h:185
iterator & operator++()
Definition: ut0lst.h:197
elem_type * m_prev_elem
Definition: ut0lst.h:182
A helper wrapper class for the list, which exposes begin(),end() iterators which let you remove the c...
Definition: ut0lst.h:173
ut_list_base & m_list
Definition: ut0lst.h:175
iterator begin()
Definition: ut0lst.h:220
Removable(ut_list_base &list)
Definition: ut0lst.h:219
iterator end()
Definition: ut0lst.h:221
base_iterator & operator++()
Definition: ut0lst.h:155
bool operator==(const base_iterator &other) const
Definition: ut0lst.h:148
E * operator*() const
Definition: ut0lst.h:154
E * m_elem
Definition: ut0lst.h:144
base_iterator(E *elem)
Definition: ut0lst.h:147
bool operator!=(const base_iterator &other) const
Definition: ut0lst.h:151
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1076
static int count
Definition: myisam_ftdump.cc:45
Type
Definition: resource_group_basic_types.h:33
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
void operator()(const void *)
Definition: ut0lst.h:454
static const ut_list_node< Type > & get_node(const Type &element)
Definition: ut0lst.h:246
The two-way list base node.
Definition: ut0lst.h:81
static const elem_type * next(const elem_type &e)
Definition: ut0lst.h:90
iterator end()
Definition: ut0lst.h:165
const_iterator begin() const
Definition: ut0lst.h:166
static elem_type * next(elem_type &e)
Definition: ut0lst.h:91
elem_type * first_element
Pointer to list start, NULL if empty.
Definition: ut0lst.h:100
elem_type * last_element
Pointer to list end, NULL if empty.
Definition: ut0lst.h:102
const_iterator end() const
Definition: ut0lst.h:167
void update_length(int diff)
Updates the length of the list by the amount specified.
Definition: ut0lst.h:118
std::atomic< size_t > count
Number of nodes in list.
Definition: ut0lst.h:139
void clear()
Definition: ut0lst.h:123
static elem_type * prev(elem_type &e)
Definition: ut0lst.h:95
static const node_type & get_node(const elem_type &e)
Definition: ut0lst.h:84
static const elem_type * prev(const elem_type &e)
Definition: ut0lst.h:94
iterator begin()
Definition: ut0lst.h:164
size_t get_length() const
Returns number of nodes currently present in the list.
Definition: ut0lst.h:111
Type elem_type
Definition: ut0lst.h:82
void reverse()
Definition: ut0lst.h:130
static node_type & get_node(elem_type &e)
Definition: ut0lst.h:87
Removable removable()
Returns a wrapper which lets you remove current item or items after it.
Definition: ut0lst.h:242
ulint init
UT_LIST_INITIALISED if the list was initialised with the constructor.
Definition: ut0lst.h:107
The two way list node.
Definition: ut0lst.h:50
Type * prev
pointer to the previous node, NULL if start of list
Definition: ut0lst.h:51
void reverse()
Definition: ut0lst.h:56
Type * next
pointer to next node, NULL if end of list
Definition: ut0lst.h:53
unsigned long int ulint
Definition: univ.i:406
Debug utilities for Innobase.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
#define UT_LIST_IS_INITIALISED(b)
Definition: ut0lst.h:70
void ut_list_validate(const List &list, Functor &functor)
Checks the consistency of a two-way list.
Definition: ut0lst.h:493
void ut_list_map(const List &list, Functor &functor)
Iterate over all the elements and call the functor for each element.
Definition: ut0lst.h:461
void ut_list_prepend(List &list, typename List::elem_type *elem)
Adds the node as the first element in a two-way linked list.
Definition: ut0lst.h:295
void ut_list_remove(List &list, typename List::elem_type *elem)
Removes a node from a two-way linked list.
Definition: ut0lst.h:397
#define UT_LIST_INITIALISED
Definition: ut0lst.h:67
void ut_list_append(List &list, typename List::elem_type *elem)
Adds the node as the last element in a two-way linked list.
Definition: ut0lst.h:328
void ut_list_reverse(List &list)
Definition: ut0lst.h:475
void ut_list_insert(List &list, typename List::elem_type *elem1, typename List::elem_type *elem2)
Inserts a ELEM2 after ELEM1 in a list.
Definition: ut0lst.h:361
void ut_list_move_to_front(List &list, typename List::elem_type *elem)
Move the given element to the beginning of the list.
Definition: ut0lst.h:519
bool ut_list_exists(List &list, typename List::elem_type *elem)
Check if the given element exists in the list.
Definition: ut0lst.h:533