Changeset 72 for Generics/TemplateGenerics/Generic/DictionaryInterface.tpl
- Timestamp:
- Oct 28, 2010, 4:52:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Generic/DictionaryInterface.tpl
r71 r72 1 1 2 TGListSortCompare = function(const Item1, Item2: TListItem): Integer of object; 3 TGListStringConverter = function(Item: TListItem): string; 4 //TGListNotification = (lnAdded, lnExtracted, lnDeleted); 2 TGDictionary = class; 5 3 6 // TGList<TListIndex, TListItem> = class 7 TGList = class 4 TGPair = record 5 Key: TDictionaryKey; 6 Value: TDictionaryValue; 7 end; 8 9 TListIndex = TDictionaryIndex; 10 TListItem = TGPair; 11 {$INCLUDE 'ListInterface.tpl'} 12 13 // TGDictionary<TDictionaryIndex, TDictionaryKey, TDictionaryValue> = class(TGList) 14 TGDictionary = class(TGList) 8 15 private 9 FItems: array of TListItem; 10 FCount: TListIndex; 11 function Get(Index: TListIndex): TListItem; 12 function GetCount: TListIndex; 13 function GetCapacity: TListIndex; 14 procedure SetCapacity(const AValue: TListIndex); 15 procedure Put(Index: TListIndex; const AValue: TListItem); 16 procedure SetCount(const AValue: TListIndex); 17 procedure QuickSort(L, R : TListIndex; Compare: TGListSortCompare); 18 property Capacity: TListIndex read GetCapacity write SetCapacity; 16 function GetKey(Index: TDictionaryIndex): TDictionaryKey; 17 function GetValue(Key: TDictionaryKey): TDictionaryValue; 18 procedure PutKey(Index: TDictionaryIndex; const AValue: TDictionaryKey); 19 procedure PutValue(Key: TDictionaryKey; const AValue: TDictionaryValue); 19 20 public 20 // All items 21 procedure Reverse; 22 procedure Clear; 23 procedure Expand; 24 procedure Sort(Compare: TGListSortCompare); 25 function Implode(Separator: string; Converter: TGListStringConverter): string; 26 // Many items 27 procedure MoveItems(CurIndex, NewIndex, Count: TListIndex); 28 procedure Swap(Index1, Index2: TListIndex); 29 // One item 30 function Add(Item: TListItem): TListIndex; 31 procedure Delete(Index: TListIndex); 32 procedure Exchange(Index1, Index2: TListIndex); 33 function Extract(Item: TListItem): TListItem; 34 function First: TListItem; 35 function IndexOf(Item: TListItem): TListIndex; 36 procedure Insert(Index: TListIndex; Item: TListItem); 37 function Last: TListItem; 38 procedure Move(CurIndex, NewIndex: TListIndex); 39 function Remove(Item: TListItem): TListIndex; 40 property Items[Index: TListIndex]: TListItem read Get write Put; default; 41 // List 42 procedure AddList(List: TGList); 43 procedure Assign(List: TGList); 44 procedure DeleteItems(Index, Count: TListIndex); 45 //function Equals(Obj: TObject): Boolean; override; 46 procedure InsertList(Index: TListIndex; List: TGList); 47 // Other 48 property Count: TListIndex read GetCount write SetCount; 49 // Additional 50 procedure SetArray(Values: array of TListItem); 21 function SearchKey(Key: TDictionaryKey): TDictionaryIndex; 22 procedure Add(Key: TDictionaryKey; Value: TDictionaryValue); 23 property Values[Index: TDictionaryKey]: TDictionaryValue 24 read GetValue write PutValue; 25 property Keys[Index: TDictionaryIndex]: TDictionaryKey 26 read GetKey write PutKey; 51 27 end;
Note:
See TracChangeset
for help on using the changeset viewer.