Mission Base

Program Base Library Functions

int pblListSort

( PblList* list,
  int (* compare ) ( const void* prev,
  const void* next ) )

Sorts the elements of the list.

Documentation

Sorts the elements of the list.

A specific compare function can be used for the sort.

If NULL is specific as specific compare function, the compare function set for the list will be used if any, otherwise the default compare function is used.

The default compare function compares the two pointers directly.

The compare function specified should behave like the one that can be specified for the C-library function 'qsort'.

This method uses the C library function 'qsort', therefore it normally has a time complexity of O( N * Log(N) ), with N being he size of the list to sort.

For linked lists this method has a memory complexity of O(N). For array lists this method does not need memory.

Parameters:
list - The list to sort
compare - Specific compare function to use
prev - "left" element for compare
next - "right" element for compare
Returns:
int rc == 0: Ok.
int rc < 0: An error, see pbl_errno:
PBL_ERROR_OUT_OF_MEMORY - Out of memory.

Alphabetic index



This page was generated with the help of DOC++.