[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] |
Compare two items in the collection.
Source position: objects.pp line 446
function TSortedCollection.Compare( |
Key1: Pointer; |
Key2: Pointer |
):Sw_Integer; virtual; |
Compare is an abstract method that should be overridden by descendent objects in order to compare two items in the collection. This method is used in the Search method and in the Insert method to determine the ordering of the objects.
The function should compare the two keys of items and return the following function results:
An 'abstract run-time error' will be generated if you call TSortedCollection.Compare directly.
|
Return index of an item in the collection. |
|
|
Search for item with given key. |
Unit MySortC; Interface Uses Objects; Type PMySortedCollection = ^TMySortedCollection; TMySortedCollection = Object(TSortedCollection) Function Compare (Key1,Key2 : Pointer): Sw_integer; virtual; end; Implementation Uses MyObject; Function TMySortedCollection.Compare (Key1,Key2 : Pointer) :sw_integer; begin Compare:=PMyobject(Key1)^.GetField - PMyObject(Key2)^.GetField; end; end.