MySQL  8.0.12
Source Code Documentation
ut0lst.h File Reference

List utilities. More...

#include "ut0dbg.h"

Go to the source code of this file.

Classes

struct  ut_list_node< Type >
 The two way list node. More...
 
struct  ut_list_base< Type, NodePtr >
 The two-way list base node. More...
 
struct  GenericGetNode< Type >
 Functor for accessing the embedded node within a list element. More...
 
struct  NullValidate
 

Macros

#define UT_LIST_NODE_T(t)   ut_list_node<t>
 Macro used for legacy reasons. More...
 
#define UT_LIST_BASE_NODE_T(t)   ut_list_base<t, ut_list_node<t> t::*>
 
#define UT_LIST_INITIALISED   0xCAFE
 
#define UT_LIST_INITIALISE(b)   (b).init = UT_LIST_INITIALISED
 
#define UT_LIST_IS_INITIALISED(b)   ut_a(((b).init == UT_LIST_INITIALISED))
 
#define UT_LIST_INIT(b, pmf)
 Note: This is really the list constructor. More...
 
#define UT_LIST_ADD_FIRST(LIST, ELEM)   ut_list_prepend(LIST, ELEM)
 Adds the node as the first element in a two-way linked list. More...
 
#define UT_LIST_ADD_LAST(LIST, ELEM)   ut_list_append(LIST, ELEM)
 Adds the node as the last element in a two-way linked list. More...
 
#define UT_LIST_INSERT_AFTER(LIST, ELEM1, ELEM2)   ut_list_insert(LIST, ELEM1, ELEM2)
 Inserts a ELEM2 after ELEM1 in a list. More...
 
#define UT_LIST_REMOVE(LIST, ELEM)   ut_list_remove(LIST, ELEM)
 Removes a node from a two-way linked list. More...
 
#define UT_LIST_GET_NEXT(NAME, N)   (((N)->NAME).next)
 Gets the next node in a two-way list. More...
 
#define UT_LIST_GET_PREV(NAME, N)   (((N)->NAME).prev)
 Gets the previous node in a two-way list. More...
 
#define UT_LIST_GET_LEN(BASE)   (BASE).count
 Alternative macro to get the number of nodes in a two-way list, i.e., its length. More...
 
#define UT_LIST_GET_FIRST(BASE)   (BASE).start
 Gets the first node in a two-way list. More...
 
#define UT_LIST_GET_LAST(BASE)   (BASE).end
 Gets the last node in a two-way list. More...
 
#define UT_LIST_REVERSE(LIST)   ut_list_reverse(LIST)
 
#define UT_LIST_CHECK(LIST)
 Check the consistency of a two-way list. More...
 
#define UT_LIST_MOVE_TO_FRONT(LIST, ELEM)   ut_list_move_to_front(LIST, ELEM)
 

Functions

template<typename List >
void ut_list_prepend (List &list, typename List::elem_type *elem)
 Adds the node as the first element in a two-way linked list. More...
 
template<typename List , typename Functor >
void ut_list_append (List &list, typename List::elem_type *elem, Functor get_node)
 Adds the node as the last element in a two-way linked list. More...
 
template<typename List >
void ut_list_append (List &list, typename List::elem_type *elem)
 Adds the node as the last element in a two-way linked list. More...
 
template<typename List >
void ut_list_insert (List &list, typename List::elem_type *elem1, typename List::elem_type *elem2)
 Inserts a ELEM2 after ELEM1 in a list. More...
 
template<typename List , typename Functor >
void ut_list_remove (List &list, typename List::node_type &node, Functor get_node)
 Removes a node from a two-way linked list. More...
 
template<typename List , typename Functor >
void ut_list_remove (List &list, typename List::elem_type *elem, Functor get_node)
 Removes a node from a two-way linked list. More...
 
template<typename List >
void ut_list_remove (List &list, typename List::elem_type *elem)
 Removes a node from a two-way linked list. More...
 
template<typename List , class Functor >
void ut_list_map (const List &list, Functor &functor)
 Iterate over all the elements and call the functor for each element. More...
 
template<typename List >
void ut_list_reverse (List &list)
 
template<typename List , class Functor >
void ut_list_validate (const List &list, Functor &functor)
 Checks the consistency of a two-way list. More...
 
template<typename List >
void ut_list_move_to_front (List &list, typename List::elem_type *elem)
 Move the given element to the beginning of the list. More...
 
template<typename List >
bool ut_list_exists (List &list, typename List::elem_type *elem)
 Check if the given element exists in the list. More...
 

Detailed Description

List utilities.

Created 9/10/1995 Heikki Tuuri Rewritten by Sunny Bains Dec 2011.

Macro Definition Documentation

◆ UT_LIST_ADD_FIRST

#define UT_LIST_ADD_FIRST (   LIST,
  ELEM 
)    ut_list_prepend(LIST, ELEM)

Adds the node as the first element in a two-way linked list.

Parameters
LISTthe base node (not a pointer to it)
ELEMthe element to add

◆ UT_LIST_ADD_LAST

#define UT_LIST_ADD_LAST (   LIST,
  ELEM 
)    ut_list_append(LIST, ELEM)

Adds the node as the last element in a two-way linked list.

Parameters
LISTlist base node (not a pointer to it)
ELEMthe element to add

◆ UT_LIST_BASE_NODE_T

#define UT_LIST_BASE_NODE_T (   t)    ut_list_base<t, ut_list_node<t> t::*>

◆ UT_LIST_CHECK

#define UT_LIST_CHECK (   LIST)
Value:
do { \
NullValidate nullV; \
ut_list_validate(LIST, nullV); \
} while (0)
Definition: my_list.h:41

Check the consistency of a two-way list.

Parameters
[in]LISTbase node reference

◆ UT_LIST_GET_FIRST

#define UT_LIST_GET_FIRST (   BASE)    (BASE).start

Gets the first node in a two-way list.

Parameters
BASEthe base node (not a pointer to it)
Returns
first node, or NULL if the list is empty

◆ UT_LIST_GET_LAST

#define UT_LIST_GET_LAST (   BASE)    (BASE).end

Gets the last node in a two-way list.

Parameters
BASEthe base node (not a pointer to it)
Returns
last node, or NULL if the list is empty

◆ UT_LIST_GET_LEN

#define UT_LIST_GET_LEN (   BASE)    (BASE).count

Alternative macro to get the number of nodes in a two-way list, i.e., its length.

Parameters
BASEthe base node (not a pointer to it).
Returns
the number of nodes in the list

◆ UT_LIST_GET_NEXT

#define UT_LIST_GET_NEXT (   NAME,
 
)    (((N)->NAME).next)

Gets the next node in a two-way list.

Parameters
NAMElist name
Npointer to a node
Returns
the successor of N in NAME, or NULL

◆ UT_LIST_GET_PREV

#define UT_LIST_GET_PREV (   NAME,
 
)    (((N)->NAME).prev)

Gets the previous node in a two-way list.

Parameters
NAMElist name
Npointer to a node
Returns
the predecessor of N in NAME, or NULL

◆ UT_LIST_INIT

#define UT_LIST_INIT (   b,
  pmf 
)
Value:
{ \
(b).count = 0; \
(b).start = 0; \
(b).end = 0; \
(b).node = pmf; \
UT_LIST_INITIALISE(b); \
}
ssize_t count
Definition: memcached.c:386
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191

Note: This is really the list constructor.

We should be able to use placement new here. Initializes the base node of a two-way list.

Parameters
bthe list base node
pmfpoint to member field that will be used as the link node

◆ UT_LIST_INITIALISE

#define UT_LIST_INITIALISE (   b)    (b).init = UT_LIST_INITIALISED

◆ UT_LIST_INITIALISED

#define UT_LIST_INITIALISED   0xCAFE

◆ UT_LIST_INSERT_AFTER

#define UT_LIST_INSERT_AFTER (   LIST,
  ELEM1,
  ELEM2 
)    ut_list_insert(LIST, ELEM1, ELEM2)

Inserts a ELEM2 after ELEM1 in a list.

Parameters
LISTlist base node (not a pointer to it)
ELEM1node after which ELEM2 is inserted
ELEM2node being inserted after ELEM1

◆ UT_LIST_IS_INITIALISED

#define UT_LIST_IS_INITIALISED (   b)    ut_a(((b).init == UT_LIST_INITIALISED))

◆ UT_LIST_MOVE_TO_FRONT

#define UT_LIST_MOVE_TO_FRONT (   LIST,
  ELEM 
)    ut_list_move_to_front(LIST, ELEM)

◆ UT_LIST_NODE_T

#define UT_LIST_NODE_T (   t)    ut_list_node<t>

Macro used for legacy reasons.

◆ UT_LIST_REMOVE

#define UT_LIST_REMOVE (   LIST,
  ELEM 
)    ut_list_remove(LIST, ELEM)

Removes a node from a two-way linked list.

Parameters
LISTthe base node (not a pointer to it)
ELEMnode to be removed from the list

◆ UT_LIST_REVERSE

#define UT_LIST_REVERSE (   LIST)    ut_list_reverse(LIST)

Function Documentation

◆ ut_list_append() [1/2]

template<typename List , typename Functor >
void ut_list_append ( List list,
typename List::elem_type *  elem,
Functor  get_node 
)

Adds the node as the last element in a two-way linked list.

Parameters
listlist
elemthe element to add
get_nodeto get the list node for that element

◆ ut_list_append() [2/2]

template<typename List >
void ut_list_append ( List list,
typename List::elem_type *  elem 
)

Adds the node as the last element in a two-way linked list.

Parameters
listlist
elemthe element to add

◆ ut_list_exists()

template<typename List >
bool ut_list_exists ( List list,
typename List::elem_type *  elem 
)

Check if the given element exists in the list.

Parameters
[in,out]listthe list object
[in]elemthe element of the list which will be checked

◆ ut_list_insert()

template<typename List >
void ut_list_insert ( List list,
typename List::elem_type *  elem1,
typename List::elem_type *  elem2 
)

Inserts a ELEM2 after ELEM1 in a list.

Parameters
listthe base node
elem1node after which ELEM2 is inserted
elem2node being inserted after ELEM1

◆ ut_list_map()

template<typename List , class Functor >
void ut_list_map ( const List list,
Functor &  functor 
)

Iterate over all the elements and call the functor for each element.

Parameters
[in]listbase node (not a pointer to it)
[in,out]functorFunctor that is called for each element in the list

◆ ut_list_move_to_front()

template<typename List >
void ut_list_move_to_front ( List list,
typename List::elem_type *  elem 
)

Move the given element to the beginning of the list.

Parameters
[in,out]listthe list object
[in]elemthe element of the list which will be moved to the beginning of the list.

◆ ut_list_prepend()

template<typename List >
void ut_list_prepend ( List list,
typename List::elem_type *  elem 
)

Adds the node as the first element in a two-way linked list.

Parameters
listthe base node (not a pointer to it)
elemthe element to add

◆ ut_list_remove() [1/3]

template<typename List , typename Functor >
void ut_list_remove ( List list,
typename List::node_type &  node,
Functor  get_node 
)

Removes a node from a two-way linked list.

Parameters
listthe base node (not a pointer to it)
nodemember node within list element that is to be removed
get_nodefunctor to get the list node from elem

◆ ut_list_remove() [2/3]

template<typename List , typename Functor >
void ut_list_remove ( List list,
typename List::elem_type *  elem,
Functor  get_node 
)

Removes a node from a two-way linked list.

Parameters
listthe base node (not a pointer to it)
elemelement to be removed from the list
get_nodefunctor to get the list node from elem

◆ ut_list_remove() [3/3]

template<typename List >
void ut_list_remove ( List list,
typename List::elem_type *  elem 
)

Removes a node from a two-way linked list.

Parameters
listthe base node (not a pointer to it)
elemelement to be removed from the list

◆ ut_list_reverse()

template<typename List >
void ut_list_reverse ( List list)

◆ ut_list_validate()

template<typename List , class Functor >
void ut_list_validate ( const List list,
Functor &  functor 
)

Checks the consistency of a two-way list.

Parameters
[in]listbase node (not a pointer to it)
[in,out]functorFunctor that is called for each element in the list