Mission Base

Program Base Library Functions

void* pblCollectionSetCompareFunction

( PblCollection* collection,
  int (* compare ) ( const void* prev,
  const void* next ) )

Sets an application specific compare function for the elements of the collection.

Documentation

Sets an application specific compare function for the elements of the collection.

An application specific compare function can be set to the collection only if the collection is empty.

If no specific compare function is specified by the user, the default compare function is used. The default compare function compares the two pointers directly, i.e. it tests for object identity.

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

The arguments actually passed to the compare function when it is called are addresses of the element pointers added to the collection. E.g.: If you add char * pointers to the set, the compare function will be called with char ** pointers as arguments. See the documentation for the C-library function 'qsort' for further information.

This method has a time complexity of O(1).

Parameters:
collection - The collection to set compare function for
compare - The compare function to set
prev - "left" element for compare
next - "right" element for compare
Returns:
* retptr != (void*)-1: The compare function used before, may be NULL.
* retptr == (void*)-1: An error, see pbl_errno:
PBL_ERROR_PARAM_COLLECTION - The collection is not empty.

Alphabetic index



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