HasSortKeys |
|
|
CompareItems CompareItemsBySortKey SecondarySortKeys |
|
ReverseOrder SortKey |
Define Class HasSortKeys; mixes in with ObjectList, SortedList; attribute SortKey: OperationNumber, safe, noGetter, noSetter; // a numeric key used to determine the primary criteria CompareItems should use; // must override getter to return the numeric key; // must override setter to store the numeric key somewhere, typically in a field of overriding subclass attribute ReverseOrder: Boolean, noGetter, noSetter; // determines whether the list should be sorted in reverse of normal order; // reverse order is only used for primary sort key; // must override getter to return the current value; // must override setter to store the new value, typically in a field of overriding subclass overrides CompareItems; // returns result of CompareItemsBySortKey on sort key, if result is non-zero; // otherwise calls CompareItemsBySortKey repeatedly on each SecondarySortKey // that is not the primary sort key until items are distinguished; // if primary sort key is zero, returns zero immediately; // override rarely (override CompareItemsBySortKey instead) operation CompareItemsBySortKey(index1: Unsigned; index2: Unsigned; element1: Object; element2: Object; sortKey: OperationNumber): SignedShort, noMethod; // called repeatedly by CompareItems to determine sort order; // returns -1 to sort element1 before element2 when sorting by sortKey; // returns 1 to sort element1 after element2 when sorting by sortKey; // returns 0 when element1 and element2 are not distinguished when sorting by sortKey // must override to handle all sortKeys that subclass should handle operation SecondarySortKeys(keyList: OperationNumberList); // called by CompareItems to obtain ordered list of sort keys to use if // two items are not distinguished when sorting by primary sort key; // override to add secondary sort keys to keyList; // if not overridden, only primary sort key will be used by CompareItems; // since the sorting is non-destructive, not supplying secondary keys allows // the user to control the overall order by multiple sorts. // CompareItems will ignore primary sort key if it is included in list end class;