csnip  0.1
Macros
Singly Linked Lists with tail pointers
Collaboration diagram for Singly Linked Lists with tail pointers:

Macros

#define csnip_slist_Init(head, tail, mnext)
 Initialize an slist. More...
 
#define csnip_slist_PushHead(head, tail, mnext, el)
 Push an element to the head of an slist.
 
#define csnip_slist_PopHead(head, tail, mnext)
 Pop the head of an slist. More...
 
#define csnip_slist_PushTail(head, tail, mnext, el)
 Push an element to the tail of an slist.
 
#define csnip_slist_InsertAfter(head, tail, mnext, loc, el)
 Insert an element after the end of the given location. More...
 
#define CSNIP_SLIST_DECL_FUNCS(scope, prefix, entry_ptr_type, gen_args)
 Declare slist functions. More...
 
#define CSNIP_SLIST_DEF_FUNCS(scope, prefix, entry_ptr_type, gen_args, phead, ptail, mnext)
 Define a set of slist functions. More...
 

Detailed Description

Macro Definition Documentation

◆ CSNIP_SLIST_DECL_FUNCS

#define CSNIP_SLIST_DECL_FUNCS (   scope,
  prefix,
  entry_ptr_type,
  gen_args 
)

This macro declares a set of slist functions that wrap the csnip_slist_* macros; the functions can be defined with CSNIP_SLIST_DEF_FUNCS(). For a description of the macro arguments, see CSNIP_SLIST_DEF_FUNCS().

◆ CSNIP_SLIST_DEF_FUNCS

#define CSNIP_SLIST_DEF_FUNCS (   scope,
  prefix,
  entry_ptr_type,
  gen_args,
  phead,
  ptail,
  mnext 
)
Parameters
scopethe scope of the function declaration.
prefixthe prefix for the function names.
entry_ptr_typepointer type to a list entry.
gen_argsgeneric arguments to specify the list, of the form args(...) or noargs().
pheadlvalue pointer to the list head, can be expressed in terms of the gen_args arguements
ptailLike phead, but for the list tail.
mnextThe struct entry name for pointers to the next entry.

The list functions defined, are (without the prefix):

  • void init(genargs)
  • void push_head(genargs, entry_ptr_type element)
  • void pop_head(genargs)
  • void push_tail(genargs, entry_ptr_type element)
  • void insert_after(genargs, entry_ptr_type loc, entry_ptr_type element)
  • entry_ptr_type head(genargs)
  • entry_ptr_type tail(genargs)
  • entry_ptr_type next(entry_ptr_type el)
  • char is_empty(genargs)

◆ csnip_slist_Init

#define csnip_slist_Init (   head,
  tail,
  mnext 
)
Value:
do { \
(head) = (tail) = NULL; \
} while (0)

◆ csnip_slist_InsertAfter

#define csnip_slist_InsertAfter (   head,
  tail,
  mnext,
  loc,
  el 
)
Parameters
head,tail,mnextlist description.
locpoint after which to insert (pointer to a list element).
elelement to insert.

◆ csnip_slist_PopHead

#define csnip_slist_PopHead (   head,
  tail,
  mnext 
)

Underflowing the list results in an assertion failure; therefore, only pop the list if it's known that the list is non-empty.