Sturk 1.0.2
Publish-subscribe C implementation.
Loading...
Searching...
No Matches
list.h File Reference

Singly linked list. More...

#include "vx/graph.h"
Include dependency graph for list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VX_LIST(name, type)   VX_GRAPH(name, 1, type)
 Define the list.
 
#define vx_list_foreach(type, i, listp)   vx_graph_foredge (type, i, listp, 0)
 Traverse a list.
 
#define vx_list_ins(list, ...)   VX__LIST_INS((list), __VA_ARGS__, 0, )
 Insert, at a given position, an entry into a list.
 
#define vx_list_rem(...)   VX__LIST_REM(__VA_ARGS__, 0, )
 Remove, at a given position, an entry from a list.
 

Detailed Description

Singly linked list.

This header file provides data types, functions and macros that define and operate on singly linked lists.

Macro Definition Documentation

◆ VX_LIST

#define VX_LIST (   name,
  type 
)    VX_GRAPH(name, 1, type)

Define the list.

Parameters
[in]nameThe name of the type used for the list.
[in]typeThe type of the data held by name.

This macro will define a compound type (must be struct or union) name, a type for a list entry that holds the data of the type type.

◆ vx_list_foreach

#define vx_list_foreach (   type,
  i,
  listp 
)    vx_graph_foredge (type, i, listp, 0)

Traverse a list.

Traverse the list of type type referenced by listp in the forward direcion, assigning every entry in turn to i.

◆ vx_list_ins

#define vx_list_ins (   list,
  ... 
)    VX__LIST_INS((list), __VA_ARGS__, 0, )

Insert, at a given position, an entry into a list.

A call vx_list_ins(list, entry, pos) will insert the entry into the list at the pos. To insert at the head use 0 for the pos and to insert at the tail use -1 for the pos. The argument pos is optional and by default it equals 0.

◆ vx_list_rem

#define vx_list_rem (   ...)    VX__LIST_REM(__VA_ARGS__, 0, )

Remove, at a given position, an entry from a list.

A call vx_list_rem(listp, pos) will remove an entry from the listp at the pos and will return the removed entry. To remove from the head use 0 for the pos and to remove from the tail use -1 for the pos. The argument pos is optional and by default it equals 0.

Returns
The removed entry.