libusual  0.1
Data Structures | Defines | Typedefs | Functions
usual/list.h File Reference

Circular doubly linked list. More...

Data Structures

struct  List
 Structure for both list nodes and heads. More...

Defines

#define LIST(var)
 Define and initialize emtpy list head.
#define list_pop_type(list, typ, field)
 Remove first elem from list and return with casting.
#define list_for_each(item, list)
 Loop over list.
#define list_for_each_reverse(item, list)
 Loop over list backwards.
#define list_for_each_safe(item, list, tmp)
 Loop over list and allow removing item.
#define list_for_each_reverse_safe(item, list, tmp)
 Loop over list backwards and allow removing item.

Typedefs

typedef int(* list_cmp_f )(const struct List *a, const struct List *b)
 Comparator function signature for list_sort()

Functions

static void list_init (struct List *list)
 Initialize empty list head.
static int list_empty (const struct List *list)
 Is list empty?
static struct Listlist_prepend (struct List *list, struct List *item)
 Add item to the start of the list.
static struct Listlist_append (struct List *list, struct List *item)
 Add item to the end of the list.
static struct Listlist_del (struct List *item)
 Remove item from list.
static struct Listlist_pop (struct List *list)
 Remove first from list and return.
static struct Listlist_first (const struct List *list)
 Get first elem from list.
static struct Listlist_last (const struct List *list)
 Get last elem from list.
void list_sort (struct List *list, list_cmp_f cmp_func)
 Sort list.

Detailed Description

Circular doubly linked list.


Define Documentation

#define LIST (   var)

Define and initialize emtpy list head.

#define list_pop_type (   list,
  typ,
  field 
)

Remove first elem from list and return with casting.

#define list_for_each (   item,
  list 
)

Loop over list.

#define list_for_each_reverse (   item,
  list 
)

Loop over list backwards.

#define list_for_each_safe (   item,
  list,
  tmp 
)

Loop over list and allow removing item.

#define list_for_each_reverse_safe (   item,
  list,
  tmp 
)

Loop over list backwards and allow removing item.


Typedef Documentation

typedef int(* list_cmp_f)(const struct List *a, const struct List *b)

Comparator function signature for list_sort()


Function Documentation

static void list_init ( struct List list) [inline, static]

Initialize empty list head.

References List::next, and List::prev.

Referenced by statlist_init().

static int list_empty ( const struct List list) [inline, static]

Is list empty?

References List::next.

Referenced by list_first(), list_last(), list_pop(), and statlist_empty().

static struct List* list_prepend ( struct List list,
struct List item 
) [static, read]

Add item to the start of the list.

References List::next, and List::prev.

Referenced by statlist_prepend(), and statlist_put_after().

static struct List* list_append ( struct List list,
struct List item 
) [static, read]

Add item to the end of the list.

References List::next, and List::prev.

Referenced by statlist_append(), and statlist_put_before().

static struct List* list_del ( struct List item) [static, read]

Remove item from list.

References List::next, and List::prev.

Referenced by list_pop(), and statlist_remove().

static struct List* list_pop ( struct List list) [static, read]

Remove first from list and return.

References list_del(), list_empty(), and List::next.

Referenced by statlist_pop().

static struct List* list_first ( const struct List list) [static, read]

Get first elem from list.

References list_empty(), and List::next.

Referenced by statlist_first().

static struct List* list_last ( const struct List list) [static, read]

Get last elem from list.

References list_empty(), and List::prev.

Referenced by statlist_last().

void list_sort ( struct List list,
list_cmp_f  cmp_func 
)

Sort list.

This implementation uses stable merge sort which operates in-place.