Index

dkSort

Purpose:

This is an abstract class defining a function object, containing various methods used in sorting. Some examples are a function used to extract a key from an object, or to compare keys. Its primary use is by the collection class for sorting its members.

dkSort should be implemented in a subclass to provide a specific sort function. Some examples of existing implementations of sorting methods are:

DKSortString:
for sorting a collection of string objects

DKSortDDOId:
for sorting a collection of DDO based on its item ID

DKSortDDORank:
for sorting a collection of DDO based on its ranking value

DKSortDDOIdPartTS:
for sorting a collection of DDO based on its item ID and part number, these DKDDO objects usually being the result of a text query

Class summary:

 class dkSort
 {
 public:
 
   dkSort();
   virtual dkSort();
   virtual DKAny getKey(const DKAny* anObject) const = 0;
   virtual int compare(const DKAny* first, 
                       const DKAny* second) const = 0;
   virtual DKBoolean lessThan(const DKAny* first, 
                              const DKAny* second) const = 0;   
   virtual DKBoolean greaterThan(const DKAny* first, 
                                 const DKAny* second) const = 0; 
   virtual DKBoolean equals(const DKAny* first, 
                            const DKAny* second) const = 0;
   virtual void sort(DKAny** arrayOfAny, 
                     int arrayDimension, DKBoolean order);
 };

Members:

Member functions

getKey
Extract the key of a given object. This returns a DKAny object containing the key.

Exceptions

DKUsageError
The given object is not the right type or the right structure.
virtual DKAny getKey(const DKAny* anObject) const = 0;

compare
Compares an object with another. An integer number is returned that is less than zero if the first object is smaller than the second. Zero is returned if they are equal, and an integer number greater than zero is returned if the first object is larger than the other.

Exceptions

DKUsageError
The objects are not the right type or the right structure.
virtual int compare(const DKAny* first, const DKAny* second) const = 0;

lessThan
This is a comparison method; it returns TRUE is the first object is less than the second.

Exceptions

DKUsageError
The objects are not the right type or the right structure.
virtual DKBoolean lessThan(const DKAny* first, const DKAny* second) const = 0;   

greaterThan
This is a comparison method; it returns TRUE is the first object is greater than the second.

Exceptions

DKUsageError
The objects are not the right type or the right structure.
virtual DKBoolean greaterThan(const DKAny* first, const DKAny* second) const = 0; 

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.