36 memset(l,0,
sizeof(
SJList));
41 sj_set_error(
"failed to allocate space for list elements");
56 if ((n >= list->
count)||(n >= list->
size))
return NULL;
88 printf(
"no list provided\n");
97 printf(
"append failed due to lack of memory\n");
116 if (n > list->
size + 1)
118 sj_set_error(
"attempting to insert element beyond length of list");
124 if (!list)
return NULL;
157 for (i = 0; i < list->
count;i++)
177 if (n >= list->
count)
179 sj_set_error(
"attempting to delete beyond the length of the list");
182 if (n == (list->
count - 1))
210 for (i = 0;i < list->
count;i++)
void sj_list_foreach(SJList *list, void(*function)(void *data, void *context), void *contextData)
void sj_list_append(SJList *list, void *data)
add an element to the end of the list
simple datatype abstracting the data held.
SJListElementData * elements
void * sj_list_get_nth(SJList *list, unsigned int n)
get the data stored at the nth element
SJList * sj_list_prepend(SJList *list, void *data)
SJList * sj_list_new()
create a new list
SJList * sj_list_delete_nth(SJList *list, unsigned int n)
delete the element at the nth position in the list
this is a simple list structure intended to hold an arbitrary number of elements list will automatica...
void sj_set_error(char *er)
used internally to se the error message
SJList * sj_list_insert(SJList *list, void *data, unsigned int n)
instert a new element at the position provided
int sj_list_delete_data(SJList *list, void *data)
delete the first element in the list pointing to the address of data
void sj_list_delete(SJList *list)
deletes a list that has been previously allocated
SJList * sj_list_delete_last(SJList *list)
SJList * sj_list_expand(SJList *list)
SJList * sj_list_new_size(unsigned int count)
allocate a new empty list of size 'count'
SJList * sj_list_delete_first(SJList *list)
unsigned int sj_list_get_count(SJList *list)
get the number of tracked elements in the list