48template <
typename Type>
63#define UT_LIST_NODE_T(t) ut_list_node<t>
66#define UT_LIST_INITIALISED 0xCAFE
69#define UT_LIST_IS_INITIALISED(b) ((b).init == UT_LIST_INITIALISED)
79template <
typename Type,
typename NodeGetter>
112 return count.load(std::memory_order_acquire);
140 template <
typename E>
151 return !(*
this == other);
243template <
typename Type, ut_list_node<Type> Type::*node_ptr>
246 return element.*node_ptr;
252#define UT_LIST_BASE_NODE_T(t, m) \
253 ut_list_base<t, ut_list_base_explicit_getter<t, &t::m>>
257#define UT_LIST_NODE_GETTER(t, m) t##_##m##_node_getter
269#define UT_LIST_NODE_GETTER_DEFINITION(t, m) \
270 struct UT_LIST_NODE_GETTER(t, m) \
271 : public ut_list_base_explicit_getter<t, &t::m> {};
278#define UT_LIST_BASE_NODE_T_EXTERN(t, m) \
279 ut_list_base<t, struct UT_LIST_NODE_GETTER(t, m)>
284#define UT_LIST_INIT(b) \
286 auto &list_ref = (b); \
287 new (&list_ref) std::remove_reference_t<decltype(list_ref)>(); \
293template <
typename List>
299 elem_node.prev =
nullptr;
300 elem_node.next =
list.first_element;
302 if (
list.first_element !=
nullptr) {
308 list.first_element = elem;
310 if (
list.last_element ==
nullptr) {
311 list.last_element = elem;
314 list.update_length(1);
320#define UT_LIST_ADD_FIRST(LIST, ELEM) ut_list_prepend(LIST, ELEM)
326template <
typename List>
332 elem_node.next =
nullptr;
333 elem_node.prev =
list.last_element;
335 if (
list.last_element !=
nullptr) {
341 list.last_element = elem;
343 if (
list.first_element ==
nullptr) {
344 list.first_element = elem;
347 list.update_length(1);
353#define UT_LIST_ADD_LAST(LIST, ELEM) ut_list_append(LIST, ELEM)
359template <
typename List>
361 typename List::elem_type *elem2) {
362 ut_ad(elem1 != elem2);
363 ut_ad(elem1 !=
nullptr);
364 ut_ad(elem2 !=
nullptr);
370 elem2_node.prev = elem1;
371 elem2_node.next = elem1_node.next;
372 ut_ad((elem2_node.next ==
nullptr) == (
list.last_element == elem1));
373 if (elem2_node.next !=
nullptr) {
376 list.last_element = elem2;
379 elem1_node.next = elem2;
381 list.update_length(1);
388#define UT_LIST_INSERT_AFTER(LIST, ELEM1, ELEM2) \
389 ut_list_insert(LIST, ELEM1, ELEM2)
395template <
typename List>
401 if (node.next !=
nullptr) {
404 list.last_element = node.prev;
407 if (node.prev !=
nullptr) {
410 list.first_element = node.next;
416 list.update_length(-1);
422#define UT_LIST_REMOVE(LIST, ELEM) ut_list_remove(LIST, ELEM)
428#define UT_LIST_GET_NEXT(NAME, N) (((N)->NAME).next)
434#define UT_LIST_GET_PREV(NAME, N) (((N)->NAME).prev)
440#define UT_LIST_GET_LEN(BASE) (BASE).get_length()
445#define UT_LIST_GET_FIRST(BASE) (BASE).first_element
450#define UT_LIST_GET_LAST(BASE) (BASE).last_element
459template <
typename List,
class Functor>
465 for (
auto elem :
list) {
473template <
typename List>
477 for (
auto elem =
list.first_element; elem !=
nullptr;
478 elem = List::prev(*elem)) {
485#define UT_LIST_REVERSE(LIST) ut_list_reverse(LIST)
491template <
typename List,
class Functor>
497 for (
auto elem =
list.last_element; elem !=
nullptr;
498 elem = List::prev(*elem)) {
507#define UT_LIST_CHECK(LIST) \
509 NullValidate nullV; \
510 ut_list_validate(LIST, nullV); \
517template <
typename List>
521 if (
list.first_element != elem) {
531template <
typename List>
534 for (
auto e1 :
list) {
Definition: sql_list.h:433
bool operator!=(const iterator &other) const
Definition: ut0lst.h:194
elem_type * m_elem
Definition: ut0lst.h:180
elem_type * operator*() const
Definition: ut0lst.h:195
bool operator==(const iterator &other) const
Definition: ut0lst.h:191
ut_list_base & m_list
Definition: ut0lst.h:179
iterator(ut_list_base &list, elem_type *elem)
Definition: ut0lst.h:184
iterator & operator++()
Definition: ut0lst.h:196
elem_type * m_prev_elem
Definition: ut0lst.h:181
A helper wrapper class for the list, which exposes begin(),end() iterators which let you remove the c...
Definition: ut0lst.h:172
ut_list_base & m_list
Definition: ut0lst.h:174
iterator begin()
Definition: ut0lst.h:219
Removable(ut_list_base &list)
Definition: ut0lst.h:218
iterator end()
Definition: ut0lst.h:220
base_iterator & operator++()
Definition: ut0lst.h:154
bool operator==(const base_iterator &other) const
Definition: ut0lst.h:147
E * operator*() const
Definition: ut0lst.h:153
E * m_elem
Definition: ut0lst.h:143
base_iterator(E *elem)
Definition: ut0lst.h:146
bool operator!=(const base_iterator &other) const
Definition: ut0lst.h:150
static Bigint * diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:1076
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
static evkeyval * get_node(HttpHeaders::Iterator::IteratorHandle handle)
Definition: http_common.cc:113
static int count
Definition: myisam_ftdump.cc:44
Type
Definition: resource_group_basic_types.h:32
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2877
void operator()(const void *)
Definition: ut0lst.h:453
static const ut_list_node< Type > & get_node(const Type &element)
Definition: ut0lst.h:245
The two-way list base node.
Definition: ut0lst.h:80
static const elem_type * next(const elem_type &e)
Definition: ut0lst.h:89
iterator end()
Definition: ut0lst.h:164
const_iterator begin() const
Definition: ut0lst.h:165
static elem_type * next(elem_type &e)
Definition: ut0lst.h:90
elem_type * first_element
Pointer to list start, NULL if empty.
Definition: ut0lst.h:99
elem_type * last_element
Pointer to list end, NULL if empty.
Definition: ut0lst.h:101
const_iterator end() const
Definition: ut0lst.h:166
void update_length(int diff)
Updates the length of the list by the amount specified.
Definition: ut0lst.h:117
std::atomic< size_t > count
Number of nodes in list.
Definition: ut0lst.h:138
void clear()
Definition: ut0lst.h:122
static elem_type * prev(elem_type &e)
Definition: ut0lst.h:94
static const node_type & get_node(const elem_type &e)
Definition: ut0lst.h:83
static const elem_type * prev(const elem_type &e)
Definition: ut0lst.h:93
iterator begin()
Definition: ut0lst.h:163
size_t get_length() const
Returns number of nodes currently present in the list.
Definition: ut0lst.h:110
Type elem_type
Definition: ut0lst.h:81
void reverse()
Definition: ut0lst.h:129
static node_type & get_node(elem_type &e)
Definition: ut0lst.h:86
Removable removable()
Returns a wrapper which lets you remove current item or items after it.
Definition: ut0lst.h:241
ulint init
UT_LIST_INITIALISED if the list was initialised with the constructor.
Definition: ut0lst.h:106
The two way list node.
Definition: ut0lst.h:49
Type * prev
pointer to the previous node, NULL if start of list
Definition: ut0lst.h:50
void reverse()
Definition: ut0lst.h:55
Type * next
pointer to next node, NULL if end of list
Definition: ut0lst.h:52
unsigned long int ulint
Definition: univ.i:405
Debug utilities for Innobase.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:56
#define UT_LIST_IS_INITIALISED(b)
Definition: ut0lst.h:69
void ut_list_validate(const List &list, Functor &functor)
Checks the consistency of a two-way list.
Definition: ut0lst.h:492
void ut_list_map(const List &list, Functor &functor)
Iterate over all the elements and call the functor for each element.
Definition: ut0lst.h:460
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:294
void ut_list_remove(List &list, typename List::elem_type *elem)
Removes a node from a two-way linked list.
Definition: ut0lst.h:396
#define UT_LIST_INITIALISED
Definition: ut0lst.h:66
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:327
void ut_list_reverse(List &list)
Definition: ut0lst.h:474
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:360
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:518
bool ut_list_exists(List &list, typename List::elem_type *elem)
Check if the given element exists in the list.
Definition: ut0lst.h:532