30 if(!list->
size) free(list);
33 for(
this=list->
first,next=this->
next;next;
this=next,next=next->
next)
66 new->next=list->
first;
104 new->prev=list->
last;
120 if(index<0||index>size) result=1;
123 else if(index>size/2)
125 for(index=size-index,aux=list->
last;index>0;index--,aux=aux->
prev);
140 for(aux=list->
first;index>0;index--,aux=aux->
next);
164 if(value) *value=NULL;
167 else if(list->
size==1)
195 if(value) *value=NULL;
198 else if(list->
size==1)
224 if(index<0||index>size-1) result=1;
227 else if(index>size/2)
229 for(aux=list->
last,index=size-index-1;index>0;index--,aux=aux->
prev);
230 if(value) *value=aux->
value;
238 for(aux=list->
first;index>0;index--,aux=aux->
next);
239 if(value) *value=aux->
value;
282 if(index<0||index>size-1)
289 if(index>size/2)
for(index=size-index-1,aux=list->
last;index>0;index--,aux=aux->
prev);
290 else for(aux=list->
first;index>0;index--,aux=aux->
next);
309 if(!list->
size) result=1;
326 for(aux=list->
first,ctrl=0;aux&&!ctrl;aux=aux->
next)
struct sListNode * next
Next node.
void listDelete(List list)
Deletes a list.
int listAt(List list, int index, void **value)
Provides the element at the specified position of a list.
int listRemoveAt(List list, int index, void **value)
Removes the element at the specified position of a list.
int listFst(List list, void **value)
Provides the value at the first position of a list.
int listInsertLst(List list, void *value)
Inserts an element at the end of a list.
int size
Number of elements of this linked list.
int listRemoveLst(List list, void **value)
Removes the last element of a list.
int listRemoveFst(List list, void **value)
Removes the first element of a list.
void itDelete(Iterator it)
Deletes an iterator.
Implementation of a linked list.
int listMap(List list, void(*fun)(void *))
Applies a function to the elements of a list.
int itAdd(Iterator it, void *val)
Adds an element to an iterator.
ListNode first
First node.
Linked list node structure.
struct sListNode * prev
Previous node.
int listInsertAt(List list, int index, void *value)
Inserts an new element at the specified position of a list.
Iterator listIterator(List list)
Creates an iterator from a list.
int listInsertFst(List list, void *value)
Inserts an element at the beginning of a list.
int listSize(List list)
Returns the size of a list.
void * value
Node's value.
int listLst(List list, void **value)
Provides the value at the last position of a list.
List newList(void)
Creates a list.
Iterator newIt(int size)
Creates an iterator.