Changeset 69 for Generics/TemplateGenerics/List/GenericListInterface.tpl
- Timestamp:
- Oct 27, 2010, 9:28:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/List/GenericListInterface.tpl
r68 r69 4 4 5 5 type 6 TGListSortCompare = function(const Item1, Item2: TItemType): Integer; 6 TGListSortCompare = function(const Item1, Item2: TListItem): Integer of object; 7 TGListStringConverter = function(Item: TListItem): string; 7 8 //TGListNotification = (lnAdded, lnExtracted, lnDeleted); 8 9 9 // TGList<T IndexType, TItemType> = class10 // TGList<TListIndex, TListItem> = class 10 11 TGList = class 11 12 private 12 FItems: array of T ItemType;13 FCount: T IndexType;14 function Get(Index: T IndexType): TItemType;15 function GetCount: T IndexType;16 function GetCapacity: T IndexType;17 procedure SetCapacity(const AValue: T IndexType);18 procedure Put(Index: T IndexType; const AValue: TItemType);19 procedure SetCount(const AValue: T IndexType);20 procedure QuickSort(L, R : T IndexType; Compare: TGListSortCompare);21 property Capacity: T IndexTyperead GetCapacity write SetCapacity;13 FItems: array of TListItem; 14 FCount: TListIndex; 15 function Get(Index: TListIndex): TListItem; 16 function GetCount: TListIndex; 17 function GetCapacity: TListIndex; 18 procedure SetCapacity(const AValue: TListIndex); 19 procedure Put(Index: TListIndex; const AValue: TListItem); 20 procedure SetCount(const AValue: TListIndex); 21 procedure QuickSort(L, R : TListIndex; Compare: TGListSortCompare); 22 property Capacity: TListIndex read GetCapacity write SetCapacity; 22 23 public 23 24 // All items … … 26 27 procedure Expand; 27 28 procedure Sort(Compare: TGListSortCompare); 28 function Implode(Separator: string ): string;29 function Implode(Separator: string; Converter: TGListStringConverter): string; 29 30 // Many items 30 procedure MoveItems(CurIndex, NewIndex, Count: TIndexType); 31 procedure MoveItems(CurIndex, NewIndex, Count: TListIndex); 32 procedure Swap(Index1, Index2: TListIndex); 31 33 // One item 32 function Add(Item: T ItemType): TIndexType;33 procedure Delete(Index: T IndexType);34 procedure Exchange(Index1, Index2: T IndexType);35 function Extract(Item: T ItemType): TItemType;36 function First: T ItemType;37 function IndexOf(Item: T ItemType): TIndexType;38 procedure Insert(Index: T IndexType; Item: TItemType);39 function Last: T ItemType;40 procedure Move(CurIndex, NewIndex: T IndexType);41 function Remove(Item: T ItemType): TIndexType;42 property Items[Index: T IndexType]: TItemTyperead Get write Put; default;34 function Add(Item: TListItem): TListIndex; 35 procedure Delete(Index: TListIndex); 36 procedure Exchange(Index1, Index2: TListIndex); 37 function Extract(Item: TListItem): TListItem; 38 function First: TListItem; 39 function IndexOf(Item: TListItem): TListIndex; 40 procedure Insert(Index: TListIndex; Item: TListItem); 41 function Last: TListItem; 42 procedure Move(CurIndex, NewIndex: TListIndex); 43 function Remove(Item: TListItem): TListIndex; 44 property Items[Index: TListIndex]: TListItem read Get write Put; default; 43 45 // List 44 46 procedure AddList(List: TGList); 45 47 procedure Assign(List: TGList); 46 procedure DeleteItems(Index, Count: T IndexType);47 function Equals(Obj: TObject): Boolean; override;48 function ExtractList(Item: T ItemType; Count: TIndexType): TItemType;49 procedure InsertList(Index: T IndexType; List: TGList);48 procedure DeleteItems(Index, Count: TListIndex); 49 //function Equals(Obj: TObject): Boolean; override; 50 function ExtractList(Item: TListItem; Count: TListIndex): TListItem; 51 procedure InsertList(Index: TListIndex; List: TGList); 50 52 // Other 51 property Count: T IndexTyperead GetCount write SetCount;53 property Count: TListIndex read GetCount write SetCount; 52 54 // Additional 53 procedure SetArray(Values: array of T ItemType);55 procedure SetArray(Values: array of TListItem); 54 56 end;
Note:
See TracChangeset
for help on using the changeset viewer.