Mission Base

Program Base Library Functions

void* pblSetSetCompareFunction

( PblSet* set,
  int (* compare ) ( const void* prev,
  const void* next ) )

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

Documentation

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

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

If no specific hash value function is specified by the user, the default hash value function pblSetDefaultHashValue is used. 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 set. 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:
set - The set to set compare function for
compare - 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_SET - The set is not empty.

Alphabetic index



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