drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
ut0lst.h File Reference
#include "univ.i"
Include dependency graph for ut0lst.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ut0lst_h
#define UT_LIST_BASE_NODE_T(TYPE)
#define UT_LIST_NODE_T(TYPE)
#define UT_LIST_INIT(BASE)
#define UT_LIST_ADD_FIRST(NAME, BASE, N)
#define UT_LIST_ADD_LAST(NAME, BASE, N)
#define UT_LIST_INSERT_AFTER(NAME, BASE, NODE1, NODE2)
#define UT_LIST_REMOVE_CLEAR(NAME, N)
#define UT_LIST_REMOVE(NAME, BASE, N)
#define UT_LIST_GET_NEXT(NAME, N)
#define UT_LIST_GET_PREV(NAME, N)
#define UT_LIST_GET_LEN(BASE)
#define UT_LIST_GET_FIRST(BASE)
#define UT_LIST_GET_LAST(BASE)
#define UT_LIST_VALIDATE(NAME, TYPE, BASE, ASSERTION)

Detailed Description

List utilities

Created 9/10/1995 Heikki Tuuri

Definition in file ut0lst.h.

Macro Definition Documentation

◆ ut0lst_h

#define ut0lst_h

Definition at line 28 of file ut0lst.h.

◆ UT_LIST_ADD_FIRST

#define UT_LIST_ADD_FIRST ( NAME,
BASE,
N )
Value:
{\
ut_ad(N);\
((BASE).count)++;\
((N)->NAME).next = (BASE).start;\
((N)->NAME).prev = NULL;\
if (UNIV_LIKELY((BASE).start != NULL)) {\
ut_ad((BASE).start != (N));\
(((BASE).start)->NAME).prev = (N);\
}\
(BASE).start = (N);\
if (UNIV_UNLIKELY((BASE).end == NULL)) {\
(BASE).end = (N);\
}\
}\

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

Parameters
NAMElist name
BASEthe base node (not a pointer to it)
Npointer to the node to be added to the list.

Definition at line 96 of file ut0lst.h.

◆ UT_LIST_ADD_LAST

#define UT_LIST_ADD_LAST ( NAME,
BASE,
N )
Value:
{\
ut_ad(N != NULL);\
((BASE).count)++;\
((N)->NAME).prev = (BASE).end;\
((N)->NAME).next = NULL;\
if ((BASE).end != NULL) {\
ut_ad((BASE).end != (N));\
(((BASE).end)->NAME).next = (N);\
}\
(BASE).end = (N);\
if ((BASE).start == NULL) {\
(BASE).start = (N);\
}\
}\

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

Parameters
NAMElist name
BASEthe base node (not a pointer to it)
Npointer to the node to be added to the list

Definition at line 118 of file ut0lst.h.

◆ UT_LIST_BASE_NODE_T

#define UT_LIST_BASE_NODE_T ( TYPE)
Value:
int

This macro expands to the unnamed type definition of a struct which acts as the two-way list base node. The base node contains pointers to both ends of the list and a count of nodes in the list (excluding the base node from the count).

Parameters
TYPEthe name of the list node data type

Definition at line 54 of file ut0lst.h.

◆ UT_LIST_GET_FIRST

#define UT_LIST_GET_FIRST ( BASE)
Value:
(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

Definition at line 223 of file ut0lst.h.

◆ UT_LIST_GET_LAST

#define UT_LIST_GET_LAST ( BASE)
Value:
(BASE= NULL)

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

Definition at line 234 of file ut0lst.h.

◆ UT_LIST_GET_LEN

#define UT_LIST_GET_LEN ( BASE)
Value:
(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

Definition at line 216 of file ut0lst.h.

◆ UT_LIST_GET_NEXT

#define UT_LIST_GET_NEXT ( NAME,
N )
Value:
(((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

Definition at line 200 of file ut0lst.h.

◆ UT_LIST_GET_PREV

#define UT_LIST_GET_PREV ( NAME,
N )
Value:
(((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

Definition at line 208 of file ut0lst.h.

◆ UT_LIST_INIT

#define UT_LIST_INIT ( BASE)
Value:
{\
(BASE).count = 0;\
(BASE).start = NULL;\
(BASE).end = NULL;\
}\

Initializes the base node of a two-way list.

Parameters
BASEthe list base node

Definition at line 83 of file ut0lst.h.

◆ UT_LIST_INSERT_AFTER

#define UT_LIST_INSERT_AFTER ( NAME,
BASE,
NODE1,
NODE2 )
Value:
{\
ut_ad(NODE1);\
ut_ad(NODE2);\
ut_ad((NODE1) != (NODE2));\
((BASE).count)++;\
((NODE2)->NAME).prev = (NODE1);\
((NODE2)->NAME).next = ((NODE1)->NAME).next;\
if (((NODE1)->NAME).next != NULL) {\
((((NODE1)->NAME).next)->NAME).prev = (NODE2);\
}\
((NODE1)->NAME).next = (NODE2);\
if ((BASE).end == (NODE1)) {\
(BASE).end = (NODE2);\
}\
}\

Inserts a NODE2 after NODE1 in a list.

Parameters
NAMElist name
BASEthe base node (not a pointer to it)
NODE1pointer to node after which NODE2 is inserted
NODE2pointer to node being inserted after NODE1

Definition at line 141 of file ut0lst.h.

◆ UT_LIST_NODE_T

#define UT_LIST_NODE_T ( TYPE)
Value:
struct {\
TYPE * prev; \
TYPE * next; \
}\

This macro expands to the unnamed type definition of a struct which should be embedded in the nodes of the list, the node type must be a struct. This struct contains the pointers to next and previous nodes in the list. The name of the field in the node struct should be the name given to the list.

Parameters
TYPEthe list node type name

Definition at line 73 of file ut0lst.h.

◆ UT_LIST_REMOVE

#define UT_LIST_REMOVE ( NAME,
BASE,
N )
Value:
do { \
ut_ad(N); \
ut_a((BASE).count > 0); \
((BASE).count)--; \
if (((N)->NAME).next != NULL) { \
((((N)->NAME).next)->NAME).prev = ((N)->NAME).prev; \
} else { \
(BASE).end = ((N)->NAME).prev; \
} \
if (((N)->NAME).prev != NULL) { \
((((N)->NAME).prev)->NAME).next = ((N)->NAME).next; \
} else { \
(BASE).start = ((N)->NAME).next; \
} \
UT_LIST_REMOVE_CLEAR(NAME, N); \
} while (0)

Removes a node from a two-way linked list.

Parameters
NAMElist name
BASEthe base node (not a pointer to it)
Npointer to the node to be removed from the list

Definition at line 177 of file ut0lst.h.

◆ UT_LIST_REMOVE_CLEAR

#define UT_LIST_REMOVE_CLEAR ( NAME,
N )

Invalidate the pointers in a list node.

Parameters
NAMElist name
Npointer to the node that was removed

Definition at line 168 of file ut0lst.h.

◆ UT_LIST_VALIDATE

#define UT_LIST_VALIDATE ( NAME,
TYPE,
BASE,
ASSERTION )
Value:
do { \
ulint ut_list_i_313; \
TYPE* ut_list_node_313; \
\
ut_list_node_313 = (BASE).start; \
\
for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \
ut_a(ut_list_node_313); \
ASSERTION; \
ut_ad((ut_list_node_313->NAME).next || !ut_list_i_313); \
ut_list_node_313 = (ut_list_node_313->NAME).next; \
} \
\
ut_a(ut_list_node_313 == NULL); \
\
ut_list_node_313 = (BASE).end; \
\
for (ut_list_i_313 = (BASE).count; ut_list_i_313--; ) { \
ut_a(ut_list_node_313); \
ASSERTION; \
ut_ad((ut_list_node_313->NAME).prev || !ut_list_i_313); \
ut_list_node_313 = (ut_list_node_313->NAME).prev; \
} \
\
ut_a(ut_list_node_313 == NULL); \
} while (0)

Checks the consistency of a two-way list.

Parameters
NAMEthe name of the list
TYPEnode type
BASEbase node (not a pointer to it)
ASSERTIONa condition on ut_list_node_313

Definition at line 243 of file ut0lst.h.