[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LComparator



Description:

LComparator is a PowerPlant class that is used for comparing objects. Comparators are objects that know how to compare to other objects or structures.

Methods :

The methods in this class are:

 

LComparator()  
~LComparator()  
Clone()  
Compare()  
CompareToKey()  
GetComparator()  
IsEqualTo()  
IsEqualToKey()  

Data Members:

The data members in this class are:

 

sComparator  
 

Operation:

Subclasses will need to implement the Compare() method. The compare Compare() result should be one of the following:

(Array Classes)

LComparator.h

LComparator.cp

LComparator()

Purpose:

The constructor is a placeholder, it doesn't do anything for this class.

Access:

Public

Prototype:

LComparator();
Parameters:

None

~LComparator()

Purpose:

The destructor is a placeholder, it doesn't do anything for this class.

Access:

Virtual, Public

Prototype:

~LComparator();

Clone()

Purpose:

This method simply creates this object by calling new.

Access:

Virtual, Public

Prototype:

virtual LComparator* Clone();
Parameters:

None

Return:

A pointer to a new comparator object.

Compare()

Purpose:

This method takes two pointers to data blocks, and their sizes, and determines what the result of the comparison should be.

Access:

Virtual, Public

Prototype:

virtual SInt32 Compare(
const void* inItemOne,
const void* inItemTwo,
USInt32 inSizeOne,
USInt32 inSizeTwo ) const;
Parameters:

This method has the following parameters:

 

const void*  
inItemOne  
A data pointer to the first item.  
const void*  
inItemTwo  
A data pointer to the second item.  
USInt32  
inSizeOne  
The size of the first item.  
USInt32  
inSizeTwo  
The size of the second item.  

Return:

SInt32 that indicates one of the following:

< 0 - object/data item 1 is less than object/data item 2 0 - object/data item 1 is equal to object/data item 2 > 0 -þobject/data item 1 is greater than object/data item 2

CompareToKey()

Purpose:

This method is not yet implemented.

Access:

Virtual, Public

Prototype:

virtual SInt32 CompareToKey(
const void* inItem,
USInt32 inSize,
const void* inKey) const;
Parameters:

This method has the following parameters:

 

const void*  
inItem  
The pointer to the first item.  
USInt32  
inSize  
The size of the first item.  
const void*  
inKey  
The key to compare with.  

Return:

SInt32

GetComparator()

Purpose:

This method is an accessor for sComparator. If sComparator does not yet exist, the object is created before returning from this method.

Access:

Static, Public

Prototype:

static LComparator* GetComparator();
Parameters:

None

Return:

A pointer to sComparator.

IsEqualTo()

Purpose:

This method detects whether two objects are equal.

Access:

Virtual, Public

Prototype:

virtual Boolean IsEqualTo(
const void* inItemOne,
const void* inItemTwo,
USInt32 inSizeOne,
USInt32 inSizeTwo) const;
Parameters:

This method has the following parameters:

 

const void*  
inItemOne  
A data pointer to the first item.  
const void*  
inItemTwo  
A data pointer to the second item.  
USInt32  
inSizeOne  
The size of the first item.  
USInt32  
inSizeTwo  
The size of the second item.  

Return:

Boolean indicating true if the items are equal, false otherwise.

IsEqualToKey()

Purpose:

This method compares an item to the key to see if they are identical.

Access:

Virtual, Public

Prototype:

virtual Boolean IsEqualToKey(
const void* inItem,
USInt32 inSize,
const void* inKey) const;
Parameterss:

This method has the following parameters:

 

const void*  
inItem  
The pointer to the first item.  
USInt32  
inSize  
The size of the first item.  
const void*  
inKey  
The key to compare with.  

Return:

Boolean indicating true if the items are equal, false otherwise.

sComparator

Purpose:

This data member stores the pointer to the object we use as a standard for comparisons.

Access:

Static, Protected

Prototype:

static LComparator* sComparator;

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000