GNUnet 0.22.1
Doubly-linked list
Collaboration diagram for Doubly-linked list:

Macros

#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
 Insert an element at the head of a DLL. More...
 
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
 Insert an element at the tail of a DLL. More...
 
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
 Insert an element into a DLL after the given other element. More...
 
#define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element)
 Insert an element into a DLL before the given other element. More...
 
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
 Remove an element from a DLL. More...
 
#define GNUNET_CONTAINER_MDLL_insert(mdll, head, tail, element)
 Insert an element at the head of a MDLL. More...
 
#define GNUNET_CONTAINER_MDLL_insert_tail(mdll, head, tail, element)
 Insert an element at the tail of a MDLL. More...
 
#define GNUNET_CONTAINER_MDLL_insert_after(mdll, head, tail, other, element)
 Insert an element into a MDLL after the given other element. More...
 
#define GNUNET_CONTAINER_MDLL_insert_before(mdll, head, tail, other, element)
 Insert an element into a MDLL before the given other element. More...
 
#define GNUNET_CONTAINER_MDLL_remove(mdll, head, tail, element)
 Remove an element from a MDLL. More...
 

Detailed Description

See also
Documentation

Macro Definition Documentation

◆ GNUNET_CONTAINER_DLL_insert

#define GNUNET_CONTAINER_DLL_insert (   head,
  tail,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
(element)->next = (head); \
(element)->prev = NULL; \
if ((tail) == NULL) \
(tail) = element; \
else \
(head)->prev = element; \
(head) = (element); \
} while (0)

Insert an element at the head of a DLL.

Assumes that head, tail and element are structs with prev and next fields.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to insert

Definition at line 1797 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_DLL_insert_tail

#define GNUNET_CONTAINER_DLL_insert_tail (   head,
  tail,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
(element)->prev = (tail); \
(element)->next = NULL; \
if ((head) == NULL) \
(head) = element; \
else \
(tail)->next = element; \
(tail) = (element); \
} while (0)

Insert an element at the tail of a DLL.

Assumes that head, tail and element are structs with prev and next fields.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to insert

Definition at line 1821 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_DLL_insert_after

#define GNUNET_CONTAINER_DLL_insert_after (   head,
  tail,
  other,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
(element)->prev = (other); \
if (NULL == other) \
{ \
(element)->next = (head); \
(head) = (element); \
} \
else \
{ \
(element)->next = (other)->next; \
(other)->next = (element); \
} \
if (NULL == (element)->next) \
(tail) = (element); \
else \
(element)->next->prev = (element); \
} while (0)

Insert an element into a DLL after the given other element.

Insert at the head if the other element is NULL.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
otherprior element, NULL for insertion at head of DLL
elementelement to insert

Definition at line 1846 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_DLL_insert_before

#define GNUNET_CONTAINER_DLL_insert_before (   head,
  tail,
  other,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next == NULL) && ((tail) != (element))); \
(element)->next = (other); \
if (NULL == other) \
{ \
(element)->prev = (tail); \
(tail) = (element); \
} \
else \
{ \
(element)->prev = (other)->prev; \
(other)->prev = (element); \
} \
if (NULL == (element)->prev) \
(head) = (element); \
else \
(element)->prev->next = (element); \
} while (0)

Insert an element into a DLL before the given other element.

Insert at the tail if the other element is NULL.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
otherprior element, NULL for insertion at head of DLL
elementelement to insert

Definition at line 1879 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_DLL_remove

#define GNUNET_CONTAINER_DLL_remove (   head,
  tail,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev != NULL) || ((head) == (element))); \
GNUNET_assert (((element)->next != NULL) || ((tail) == (element))); \
if ((element)->prev == NULL) \
(head) = (element)->next; \
else \
(element)->prev->next = (element)->next; \
if ((element)->next == NULL) \
(tail) = (element)->prev; \
else \
(element)->next->prev = (element)->prev; \
(element)->next = NULL; \
(element)->prev = NULL; \
} while (0)

Remove an element from a DLL.

Assumes that head, tail and element point to structs with prev and next fields.

Using the head or tail pointer as the element argument does NOT work with this macro. Make sure to store head/tail in another pointer and use it to remove the head or tail of the list.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to remove

Definition at line 1916 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_MDLL_insert

#define GNUNET_CONTAINER_MDLL_insert (   mdll,
  head,
  tail,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
(element)->next_ ## mdll = (head); \
(element)->prev_ ## mdll = NULL; \
if ((tail) == NULL) \
(tail) = element; \
else \
(head)->prev_ ## mdll = element; \
(head) = (element); \
} while (0)

Insert an element at the head of a MDLL.

Assumes that head, tail and element are structs with prev and next fields.

Parameters
mdllsuffix name for the next and prev pointers in the element
headpointer to the head of the MDLL
tailpointer to the tail of the MDLL
elementelement to insert

Definition at line 1947 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_MDLL_insert_tail

#define GNUNET_CONTAINER_MDLL_insert_tail (   mdll,
  head,
  tail,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
(element)->prev_ ## mdll = (tail); \
(element)->next_ ## mdll = NULL; \
if ((head) == NULL) \
(head) = element; \
else \
(tail)->next_ ## mdll = element; \
(tail) = (element); \
} while (0)

Insert an element at the tail of a MDLL.

Assumes that head, tail and element are structs with prev and next fields.

Parameters
mdllsuffix name for the next and prev pointers in the element
headpointer to the head of the MDLL
tailpointer to the tail of the MDLL
elementelement to insert

Definition at line 1972 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_MDLL_insert_after

#define GNUNET_CONTAINER_MDLL_insert_after (   mdll,
  head,
  tail,
  other,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
(element)->prev_ ## mdll = (other); \
if (NULL == other) \
{ \
(element)->next_ ## mdll = (head); \
(head) = (element); \
} \
else \
{ \
(element)->next_ ## mdll = (other)->next_ ## mdll; \
(other)->next_ ## mdll = (element); \
} \
if (NULL == (element)->next_ ## mdll) \
(tail) = (element); \
else \
(element)->next_ ## mdll->prev_ ## mdll = (element); \
} while (0)

Insert an element into a MDLL after the given other element.

Insert at the head if the other element is NULL.

Parameters
mdllsuffix name for the next and prev pointers in the element
headpointer to the head of the MDLL
tailpointer to the tail of the MDLL
otherprior element, NULL for insertion at head of MDLL
elementelement to insert

Definition at line 1998 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_MDLL_insert_before

#define GNUNET_CONTAINER_MDLL_insert_before (   mdll,
  head,
  tail,
  other,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev_ ## mdll == NULL) && ((head) != (element))); \
GNUNET_assert (((element)->next_ ## mdll == NULL) && ((tail) != (element))); \
(element)->next_ ## mdll = (other); \
if (NULL == other) \
{ \
(element)->prev = (tail); \
(tail) = (element); \
} \
else \
{ \
(element)->prev_ ## mdll = (other)->prev_ ## mdll; \
(other)->prev_ ## mdll = (element); \
} \
if (NULL == (element)->prev_ ## mdll) \
(head) = (element); \
else \
(element)->prev_ ## mdll->next_ ## mdll = (element); \
} while (0)

Insert an element into a MDLL before the given other element.

Insert at the tail if the other element is NULL.

Parameters
mdllsuffix name for the next and prev pointers in the element
headpointer to the head of the MDLL
tailpointer to the tail of the MDLL
otherprior element, NULL for insertion at head of MDLL
elementelement to insert

Definition at line 2032 of file gnunet_container_lib.h.

◆ GNUNET_CONTAINER_MDLL_remove

#define GNUNET_CONTAINER_MDLL_remove (   mdll,
  head,
  tail,
  element 
)
Value:
do \
{ \
GNUNET_assert (((element)->prev_ ## mdll != NULL) || ((head) == (element))); \
GNUNET_assert (((element)->next_ ## mdll != NULL) || ((tail) == (element))); \
if ((element)->prev_ ## mdll == NULL) \
(head) = (element)->next_ ## mdll; \
else \
(element)->prev_ ## mdll->next_ ## mdll = (element)->next_ ## mdll; \
if ((element)->next_ ## mdll == NULL) \
(tail) = (element)->prev_ ## mdll; \
else \
(element)->next_ ## mdll->prev_ ## mdll = (element)->prev_ ## mdll; \
(element)->next_ ## mdll = NULL; \
(element)->prev_ ## mdll = NULL; \
} while (0)

Remove an element from a MDLL.

Assumes that head, tail and element are structs with prev and next fields.

Parameters
mdllsuffix name for the next and prev pointers in the element
headpointer to the head of the MDLL
tailpointer to the tail of the MDLL
elementelement to remove

Definition at line 2066 of file gnunet_container_lib.h.