/builddir/build/BUILD/gru-0.1.0/src/collection/gru_list.c File Reference

#include "gru_list.h"

Functions

gru_list_tgru_list_new (gru_status_t *status)
 Creates a new list.
void gru_list_destroy (gru_list_t **list)
 Ensures that the list is properly destroyed.
uint32_t gru_list_count (const gru_list_t *list)
 Returns the number of items in a list.
const gru_node_tgru_list_append (gru_list_t *list, const void *data)
 Appends an item in the list.
gru_node_tgru_list_insert (gru_list_t *list, const void *data, uint32_t position)
 Inserts an item in the list.
gru_node_tgru_list_remove (gru_list_t *list, uint32_t position)
 Removes an item from a list.
bool gru_list_remove_item (gru_list_t *list, compare_function_t comparable, const void *other)
 Removes a node that matches a given data as returned by comparable.
const gru_node_tgru_list_get (const gru_list_t *list, uint32_t position)
 Gets a node from the list at the given position.
void gru_list_for_each_compare (const gru_list_t *list, bool uniqueness, compare_function_t comparable, const void *other, void *result)
 Traverses the list comparing the data.
void gru_list_for_each (const gru_list_t *list, handle_function_t handle, void *data)
 Traverses the list executing a set of operations.
void gru_list_for_each_ex (const gru_list_t *list, handle_function_info_t handle, void *data)
 Traverses the list executing a set of operations and passes through node information (ie.
const void * gru_list_get_item (const gru_list_t *list, compare_function_t comparable, const void *other)
 Traverses the list comparing the data.

Function Documentation

const gru_node_t* gru_list_append ( gru_list_t list,
const void *  data 
)

Appends an item in the list.

Parameters:
list The list to receive the new item
data The data for the new node
Note:
It's up to the application to make sure that the data pointer remains valid throughout the lifetime of the list
Returns:
A pointer to the new node or NULL if there's not enough memory for the new node
Examples:
collection/gru_list_test.c, and string/gru_serialize_test.c.
uint32_t gru_list_count ( const gru_list_t list  ) 

Returns the number of items in a list.

Parameters:
list A given list to check the number of items
Returns:
The number of items
Note:
The list must not be NULL
Examples:
collection/gru_list_test.c, and string/gru_split_test.c.
void gru_list_destroy ( gru_list_t **  list  ) 

Ensures that the list is properly destroyed.

Parameters:
list the list to destroy
Examples:
collection/gru_list_test.c, string/gru_serialize_test.c, string/gru_split_test.c, and string/gru_split_test_2.c.
void gru_list_for_each ( const gru_list_t list,
handle_function_t  handle,
void *  data 
)

Traverses the list executing a set of operations.

Parameters:
list The list to be traversed
handle A pointer to a function of type handle_function_t
data Payload data for the true_handle and false_handle functions
Examples:
collection/gru_list_test.c.
void gru_list_for_each_compare ( const gru_list_t list,
bool  uniqueness,
compare_function_t  comparable,
const void *  compare,
void *  result 
)

Traverses the list comparing the data.

It aborts if the uniqueness is true and the comparison returns true

Parameters:
list 
comparable 
other 
result 
void gru_list_for_each_ex ( const gru_list_t list,
handle_function_info_t  handle,
void *  data 
)

Traverses the list executing a set of operations and passes through node information (ie.

: its position)

Parameters:
list The list to be traversed
handle A pointer to a function of type handle_function_info_t
data Payload data for the true_handle and false_handle functions
const gru_node_t* gru_list_get ( const gru_list_t list,
uint32_t  position 
)

Gets a node from the list at the given position.

Parameters:
list the list
position the position
Returns:
the node or NULL if not existent
Examples:
collection/gru_list_test.c, string/gru_split_test.c, and string/gru_split_test_2.c.
const void* gru_list_get_item ( const gru_list_t list,
compare_function_t  comparable,
const void *  other 
)

Traverses the list comparing the data.

It aborts if the uniqueness is true and the comparison returns true

Parameters:
list 
comparable 
other 
result 
gru_node_t* gru_list_insert ( gru_list_t list,
const void *  data,
uint32_t  position 
)

Inserts an item in the list.

Parameters:
list The list to receive the new item
data The data for the new node
position The position to insert the data
Returns:
A pointer to the new node
Examples:
collection/gru_list_test.c.
gru_list_t* gru_list_new ( gru_status_t status  ) 

Creates a new list.

Returns:
A new gru_list_t object
Examples:
collection/gru_list_test.c, and string/gru_serialize_test.c.
gru_node_t* gru_list_remove ( gru_list_t list,
uint32_t  position 
)

Removes an item from a list.

Parameters:
list The list to remove the item
position The position of the item to be removed
Returns:
A pointer to the removed node
Examples:
collection/gru_list_test.c.
bool gru_list_remove_item ( gru_list_t list,
compare_function_t  comparable,
const void *  other 
)

Removes a node that matches a given data as returned by comparable.

Parameters:
list The list to remove the node from
comparable The comparison function (void *result will be NULL)
other The data to compare the node with
Returns:
true if the node was removed or false if it was not found
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 10 Feb 2018 for GRU - Generic Reusable Utilities by  doxygen 1.6.1