* Added sort method to TCollection

git-svn-id: trunk@12901 -
This commit is contained in:
michael 2009-03-15 15:46:50 +00:00
parent 02bfd45775
commit a43bda5052
2 changed files with 13 additions and 0 deletions

View File

@ -428,6 +428,7 @@ type
TCollectionItemClass = class of TCollectionItem;
TCollectionNotification = (cnAdded, cnExtracting, cnDeleting);
TCollectionSortCompare = function (Item1, Item2: TCollectionItem): Integer;
TCollection = class(TPersistent)
private
@ -467,6 +468,7 @@ type
function GetNamePath: string; override;
function Insert(Index: Integer): TCollectionItem;
function FindItemID(ID: Integer): TCollectionItem;
procedure Sort(Const Compare : TCollectionSortCompare);
property Count: Integer read GetCount;
property ItemClass: TCollectionItemClass read FItemClass;
property Items[Index: Integer]: TCollectionItem read GetItem write SetItem;

View File

@ -329,6 +329,17 @@ procedure TCollection.Notify(Item: TCollectionItem;Action: TCollectionNotificati
begin
end;
procedure TCollection.Sort(Const Compare : TCollectionSortCompare);
begin
BeginUpdate;
try
FItems.Sort(TListSortCompare(Compare));
Finally
EndUpdate;
end;
end;
{****************************************************************************}
{* TOwnedCollection *}