PrgT_List_Compare_Proc
Abstract
Callback: Called to compare two list elements.
Syntax
PrgT_List_Compare_Proc (elem1_ptr, elem2_ptr)
| Argument | Type | Description |
|---|---|---|
elem1_ptr |
const void * |
The first element |
elem2_ptr |
const void * |
The second element |
Return Type
int
Result of the comparison (see Details).
Header
prg.h
Details
This callback should accept two arguments that are both pointers to the type of data structure or simple data type elements stored in the list-of-interest. The callback should return one of the following values to indicate the precedence relationship between the two elements:
- 1—if elem1 should be closer to the list head than elem2
- 0—if elem1 and elem2 are equal in rank
- -1—if elem2 should be closer to the list head than elem1
Two example comparison procedure declarations are shown below:
int
comp_proc1 (Packet *aptr, Packet *bptr)
int
comp_proc2 (char *aptr, char *bptr)
This callback is used by the following functions: