u_simple_list.h File Reference

Go to the source code of this file.

Defines

#define remove_from_list(elem)
 Remove an element from list.
#define insert_at_head(list, elem)
 Insert an element to the list head.
#define insert_at_tail(list, elem)
 Insert an element to the list tail.
#define move_to_head(list, elem)
 Move an element to the list head.
#define move_to_tail(list, elem)
 Move an element to the list tail.
#define make_empty_list(sentinal)
 Make a empty list empty.
#define first_elem(list)   ((list)->next)
 Get list first element.
#define last_elem(list)   ((list)->prev)
 Get list last element.
#define next_elem(elem)   ((elem)->next)
 Get next element.
#define prev_elem(elem)   ((elem)->prev)
 Get previous element.
#define at_end(list, elem)   ((elem) == (list))
 Test whether element is at end of the list.
#define is_empty_list(list)   ((list)->next == (list))
 Test if a list is empty.
#define foreach(ptr, list)   for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next )
 Walk through the elements of a list.
#define foreach_s(ptr, t, list)   for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next)
 Walk through the elements of a list.


Define Documentation

#define at_end ( list,
elem   )     ((elem) == (list))

Test whether element is at end of the list.

Parameters:
list list.
elem element.
Returns:
non-zero if element is at end of list, or zero otherwise.

Definition at line 158 of file u_simple_list.h.

#define first_elem ( list   )     ((list)->next)

Get list first element.

Parameters:
list list.
Returns:
pointer to first element.

Definition at line 121 of file u_simple_list.h.

#define foreach ( ptr,
list   )     for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next )

Walk through the elements of a list.

Parameters:
ptr pointer to the current element.
list list.
Note:
It should be followed by a { } block or a single statement, as in a for loop.

Definition at line 178 of file u_simple_list.h.

#define foreach_s ( ptr,
t,
list   )     for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next)

Walk through the elements of a list.

Same as foreach but lets you unlink the current value during a list traversal. Useful for freeing a list, element by element.

Parameters:
ptr pointer to the current element.
t temporary pointer.
list list.
Note:
It should be followed by a { } block or a single statement, as in a for loop.

Definition at line 194 of file u_simple_list.h.

#define insert_at_head ( list,
elem   ) 

Value:

do {                                            \
   (elem)->prev = list;                         \
   (elem)->next = (list)->next;                 \
   (list)->next->prev = elem;                   \
   (list)->next = elem;                         \
} while(0)
Insert an element to the list head.

Parameters:
list list.
elem element to insert.

Definition at line 57 of file u_simple_list.h.

#define insert_at_tail ( list,
elem   ) 

Value:

do {                                            \
   (elem)->next = list;                         \
   (elem)->prev = (list)->prev;                 \
   (list)->prev->next = elem;                   \
   (list)->prev = elem;                         \
} while(0)
Insert an element to the list tail.

Parameters:
list list.
elem element to insert.

Definition at line 71 of file u_simple_list.h.

#define is_empty_list ( list   )     ((list)->next == (list))

Test if a list is empty.

Parameters:
list list.
Returns:
non-zero if list empty, or zero otherwise.

Definition at line 167 of file u_simple_list.h.

#define last_elem ( list   )     ((list)->prev)

Get list last element.

Parameters:
list list.
Returns:
pointer to last element.

Definition at line 130 of file u_simple_list.h.

#define make_empty_list ( sentinal   ) 

Value:

do {                                            \
   (sentinal)->next = sentinal;                 \
   (sentinal)->prev = sentinal;                 \
} while (0)
Make a empty list empty.

Parameters:
sentinal list (sentinal element).

Definition at line 108 of file u_simple_list.h.

#define move_to_head ( list,
elem   ) 

Value:

do {                                            \
   remove_from_list(elem);                      \
   insert_at_head(list, elem);                  \
} while (0)
Move an element to the list head.

Parameters:
list list.
elem element to move.

Definition at line 85 of file u_simple_list.h.

#define move_to_tail ( list,
elem   ) 

Value:

do {                                            \
   remove_from_list(elem);                      \
   insert_at_tail(list, elem);                  \
} while (0)
Move an element to the list tail.

Parameters:
list list.
elem element to move.

Definition at line 97 of file u_simple_list.h.

#define next_elem ( elem   )     ((elem)->next)

Get next element.

Parameters:
elem element.
Returns:
pointer to next element.

Definition at line 139 of file u_simple_list.h.

#define prev_elem ( elem   )     ((elem)->prev)

Get previous element.

Parameters:
elem element.
Returns:
pointer to previous element.

Definition at line 148 of file u_simple_list.h.

#define remove_from_list ( elem   ) 

Value:

do {                                            \
   (elem)->next->prev = (elem)->prev;           \
   (elem)->prev->next = (elem)->next;           \
} while (0)
Remove an element from list.

Parameters:
elem element to remove.

Definition at line 45 of file u_simple_list.h.


Generated on Tue Sep 29 06:25:29 2009 for Gallium3D by  doxygen 1.5.4