Next: , Up: Bitmapped B-tree Fixed Size Data Arrays   [Index]


1.1.2.1 The Data Comparison Method

The method determines if the data item making the object of current operation is less, equal or greater than some B-tree stored data item. It returns negatively, zero or positively respectively. Its signature is:

int (*) (void *, void *);

The first argument is the (application specified) operation context, the second the B-tree stored data item. While the data item making the object of current operation is not explicitly present in the parameters list it is assumed to be included in the operation context.

The method is seldom used.

13 byte string data items example:

/*
 * the item making the object of current operation is the operation context
 * itself
 */
static int
fare(void *text, void *node)
{
    return memcmp(text, node, 13);
}

Unsigned long data items example:

/*
 * the item making the object of current operation is stored where the
 * operation context points
 */
static int
fare(void *text, void *node)
{
    return *(unsigned long *) text < *(unsigned long *) node
	? -1 : *(unsigned long *) text ^ *(unsigned long *) node ? 1 : 0;
}