Linked List Ordering Functions

Functions that change the ordering of data in a linked list. More...

Functions

Evas_Listevas_list_reverse (Evas_List *list)
 Reverse all the elements in the list.
Evas_Listevas_list_sort (Evas_List *list, int size, int(*func)(void *, void *))
 Sort a list according to the ordering func will return.

Detailed Description

Functions that change the ordering of data in a linked list.


Function Documentation

Evas_List* evas_list_reverse Evas_List list  ) 
 

Reverse all the elements in the list.

Parameters:
list The list to reverse
Returns:
The list after it has been reversed
This takes a list list, and reverses the order of all elements in the list, so the last member is now first, and so on.

Example:

 extern Evas_List *list;

 list = evas_list_reverse(list);

Evas_List* evas_list_sort Evas_List list,
int  size,
int(*)(void *, void *)  func
 

Sort a list according to the ordering func will return.

Parameters:
list The list handle to sort
size The length of the list to sort
func A function pointer that can handle comparing the list data nodes
Returns:
A new sorted list
This function sorts your list. The data in your nodes can be arbitrary, you just have to be smart enough to know what kind of data is in your lists

In the event of a memory allocation failure, It might segv.

Example:

 int
 sort_cb(void *d1, void *d2)
 {
   const char *txt = NULL;
    const char *txt2 = NULL;

    if(!d1) return(1);
    if(!d2) return(-1);

    return(strcmp((const char*)d1, (const char*)d2));
 }
 extern Evas_List *list;

 list = evas_list_sort(list, evas_list_count(list), sort_cb);
 if (evas_list_alloc_error())
   {
     fprintf(stderr, "ERROR: Memory is low. List Sorting failed.\n");
     exit(-1);
   }