Menustuff added/modified!
This commit is contained in:
+24
@@ -743,6 +743,30 @@ LL_Find (LinkedList * list, int compare (void *, void *), void *value)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Array like...
|
||||
// Goes to the nth list item, and returns the
|
||||
// data found there.
|
||||
//
|
||||
void *
|
||||
LL_GetByIndex (LinkedList * list, int index)
|
||||
{
|
||||
LL_node *node;
|
||||
int num = 0;
|
||||
|
||||
if (!list)
|
||||
return NULL;
|
||||
if (index<0)
|
||||
return NULL;
|
||||
|
||||
for (node = list->head.next; node != &list->tail; node = node->next) {
|
||||
if (num == index)
|
||||
return node->data;
|
||||
num ++;
|
||||
}
|
||||
return NULL; // got past the end
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sorts the list, then rewinds it...
|
||||
//
|
||||
|
||||
+7
-4
@@ -30,7 +30,7 @@
|
||||
|
||||
For errors, the general convention is that "0" means success, and
|
||||
a negative number means failure. Check LL.c to be sure, though.
|
||||
|
||||
|
||||
*******************************************************************
|
||||
|
||||
To change the data, try this:
|
||||
@@ -73,12 +73,12 @@
|
||||
my_data = (my_data *)LL_Get(list);
|
||||
... do something to it ...
|
||||
} while(LL_Next(list) == 0);
|
||||
|
||||
|
||||
*******************************************************************
|
||||
|
||||
|
||||
You can also treat the list like a stack, or a queue. Just use the
|
||||
following functions:
|
||||
|
||||
|
||||
LL_Push() // Regular stack stuff: add, remove, peek, rotate
|
||||
LL_Pop()
|
||||
LL_Top()
|
||||
@@ -191,6 +191,9 @@ int LL_Length (LinkedList * list); // Returns # of nodes in entire list
|
||||
// Searching...
|
||||
void *LL_Find (LinkedList * list, int compare (void *, void *), void *value);
|
||||
|
||||
// Array operation...
|
||||
void *LL_GetByIndex (LinkedList * list, int index); // gets the nth node, 0 being the first
|
||||
|
||||
// Sorts the list...
|
||||
int LL_Sort (LinkedList * list, int compare (void *, void *));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user