My Project
Classes | Typedefs | Functions
Generic Linked List

Classes

struct  MMAL_LIST_ELEMENT_T
struct  MMAL_LIST_T

Typedefs

typedef struct MMAL_LIST_ELEMENT_T MMAL_LIST_ELEMENT_T
typedef struct MMAL_LIST_T MMAL_LIST_T
typedef int(* MMAL_LIST_COMPARE_T )(MMAL_LIST_ELEMENT_T *lhs, MMAL_LIST_ELEMENT_T *rhs)

Functions

MMAL_LIST_Tmmal_list_create (void)
void mmal_list_destroy (MMAL_LIST_T *list)
MMAL_LIST_ELEMENT_Tmmal_list_pop_back (MMAL_LIST_T *list)
MMAL_LIST_ELEMENT_Tmmal_list_pop_front (MMAL_LIST_T *list)
void mmal_list_push_front (MMAL_LIST_T *list, MMAL_LIST_ELEMENT_T *element)
void mmal_list_push_back (MMAL_LIST_T *list, MMAL_LIST_ELEMENT_T *element)
void mmal_list_insert (MMAL_LIST_T *list, MMAL_LIST_ELEMENT_T *element, MMAL_LIST_COMPARE_T compare)

Detailed Description

This provides a thread-safe implementation of a linked list which can be used with any data type.


Typedef Documentation

List comparison function. This is supplied by a client when inserting an element in the middle of the list. The list will always insert a smaller element in front of a larger element.

Returns:
TRUE: lhs < rhs FALSE: lhs >= rhs

Single element in the list

typedef struct MMAL_LIST_T MMAL_LIST_T

Linked list type. Clients shouldn't modify this directly. Use the provided API functions to add new elements. The public members are only for debug purposes.


Function Documentation

Create a new linked list.

Returns:
Pointer to new queue (NULL on failure).
void mmal_list_destroy ( MMAL_LIST_T list)

Destroy a linked list.

Parameters:
listList to destroy
void mmal_list_insert ( MMAL_LIST_T list,
MMAL_LIST_ELEMENT_T element,
MMAL_LIST_COMPARE_T  compare 
)

Insert an element into the list. The location where the element is inserted is determined using the supplied comparison function. Smaller elements are inserted in front of larger elements.

Parameters:
listList to add to
elementThe element to insert
compareComparison function supplied by the client

Remove the last element in the list.

Parameters:
listList to remove from
Returns:
Pointer to the last element (or NULL if empty)

Remove the first element in the list.

Parameters:
listList to remove from
Returns:
Pointer to the first element (or NULL if empty)
void mmal_list_push_back ( MMAL_LIST_T list,
MMAL_LIST_ELEMENT_T element 
)

Add an element to the back of the list.

Parameters:
listList to add to
elementThe element to add
void mmal_list_push_front ( MMAL_LIST_T list,
MMAL_LIST_ELEMENT_T element 
)

Add an element to the front of the list.

Parameters:
listList to add to
elementThe element to add
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines