Ignore:
Timestamp:
Oct 31, 2010, 3:14:23 PM (14 years ago)
Author:
george
Message:
  • Modified: Thanks to compiler directives and simple macros specialized types was moved to one unit per base generic class. Directive $DEFINE is used to specify generic class template parameters which will be included to code. This approach enable to define more specialized types per unit.
Location:
Generics/TemplateGenerics/Generic
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericDictionary.inc

    r83 r84  
    44
    55  TGPair = record
    6     Key: TDictionaryKey;
    7     Value: TDictionaryValue;
     6    Key: TGPairKey;
     7    Value: TGPairValue;
    88  end;
    99
    10   TListIndex = TDictionaryIndex;
    11   TListItem = TGPair;
    12   {$DEFINE INTERFACE}
    13   {$INCLUDE 'GenericList.inc'}
     10{$DEFINE TGListIndex := TGDictionaryIndex}
     11{$DEFINE TGListItem := TGPair}
     12{$DEFINE TGList := TGDictionaryList}
     13{$DEFINE TGListSortCompare := TDictionarySortCompare}
     14{$DEFINE TGListStringConverter := TDictionaryStringConverter}
     15{$DEFINE INTERFACE}
     16{$INCLUDE 'GenericList.inc'}
    1417
    15   // TGDictionary<TDictionaryIndex, TDictionaryKey, TDictionaryValue> = class(TGList)
     18  // TGDictionary<TGDictionaryIndex, TGPair<TGPairKey, TGPairValue>> = class(TGList)
    1619  TGDictionary = class(TGList)
    1720  private
    18     function GetKey(Index: TDictionaryIndex): TDictionaryKey;
    19     function GetValue(Key: TDictionaryKey): TDictionaryValue;
    20     procedure PutKey(Index: TDictionaryIndex; const AValue: TDictionaryKey);
    21     procedure PutValue(Key: TDictionaryKey; const AValue: TDictionaryValue);
     21    function GetKey(Index: TGDictionaryIndex): TGPairKey;
     22    function GetValue(Key: TGPairKey): TGPairValue;
     23    procedure PutKey(Index: TGDictionaryIndex; const AValue: TGPairKey);
     24    procedure PutValue(Key: TGPairKey; const AValue: TGPairValue);
    2225  public
    23     function SearchKey(Key: TDictionaryKey): TDictionaryIndex;
    24     procedure Add(Key: TDictionaryKey; Value: TDictionaryValue);
    25     property Values[Index: TDictionaryKey]: TDictionaryValue
     26    function SearchKey(Key: TGPairKey): TGDictionaryIndex;
     27    procedure Add(Key: TGPairKey; Value: TGPairValue);
     28    property Values[Index: TGPairKey]: TGPairValue
    2629      read GetValue write PutValue;
    27     property Keys[Index: TDictionaryIndex]: TDictionaryKey
     30    property Keys[Index: TGDictionaryIndex]: TGPairKey
    2831      read GetKey write PutKey;
    2932  end;
     
    3437{$IFDEF IMPLEMENTATION}
    3538
     39{$UNDEF IMPLEMENTATION}
     40{$DEFINE IMPLEMENTATION_USES}
     41{$INCLUDE '..\Generic\GenericList.inc'}
    3642
     43{$DEFINE TGListIndex := TGDictionaryIndex}
     44{$DEFINE TGListItem := TGPair}
     45{$DEFINE TGList := TGDictionaryList}
     46{$DEFINE TGListSortCompare := TDictionarySortCompare}
     47{$DEFINE TGListStringConverter := TDictionaryStringConverter}
    3748{$DEFINE IMPLEMENTATION}
    3849{$INCLUDE 'GenericList.inc'}
    3950
    40 function TGDictionary.GetKey(Index: TDictionaryIndex): TDictionaryKey;
     51function TGDictionary.GetKey(Index: TGDictionaryIndex): TGPairKey;
    4152begin
    4253  Result := Items[Index].Key;
    4354end;
    4455
    45 function TGDictionary.GetValue(Key: TDictionaryKey): TDictionaryValue;
     56function TGDictionary.GetValue(Key: TGPairKey): TGPairValue;
    4657begin
    4758  Result := Items[SearchKey(Key)].Value;
    4859end;
    4960
    50 procedure TGDictionary.PutKey(Index: TDictionaryIndex;
    51   const AValue: TDictionaryKey);
     61procedure TGDictionary.PutKey(Index: TGDictionaryIndex;
     62  const AValue: TGPairKey);
    5263var
    5364  Item: TGPair;
     
    5970end;
    6071
    61 procedure TGDictionary.PutValue(Key: TDictionaryKey;
    62   const AValue: TDictionaryValue);
     72procedure TGDictionary.PutValue(Key: TGPairKey;
     73  const AValue: TGPairValue);
    6374var
    6475  Item: TGPair;
    65   Index: TDictionaryIndex;
     76  Index: TGDictionaryIndex;
    6677begin
    6778  //Items[SearchKey(Index)].Value := AValue;
     
    7283end;
    7384
    74 function TGDictionary.SearchKey(Key: TDictionaryKey): TDictionaryIndex;
     85function TGDictionary.SearchKey(Key: TGPairKey): TGDictionaryIndex;
    7586begin
    7687  Result := 0;
     
    8394end;
    8495
    85 procedure TGDictionary.Add(Key: TDictionaryKey; Value: TDictionaryValue);
     96procedure TGDictionary.Add(Key: TGPairKey; Value: TGPairValue);
    8697var
    8798  NewPair: TGPair;
     
    92103end;
    93104
     105{$UNDEF IMPLEMENTATION}
    94106{$ENDIF}
  • Generics/TemplateGenerics/Generic/GenericList.inc

    r83 r84  
    11{$IFDEF INTERFACE}
    22
    3   PGListItem = ^TListItem;
    43  TGList = class;
    54
    6   TGListSortCompare = function(const Item1, Item2: TListItem): Integer of object;
    7   TGListStringConverter = function(Item: TListItem): string;
    8   TGListOperation = procedure(List: TGList; Item: PGListItem);
     5  TGListSortCompare = function(const Item1, Item2: TGListItem): Integer of object;
     6  TGListStringConverter = function(Item: TGListItem): string;
    97  //TGListNotification = (lnAdded, lnExtracted, lnDeleted);
    108
    11   // TGList<TListIndex, TListItem> = class
     9  // TGList<TGListIndex, TGListItem> = class
    1210  TGList = class
    1311  private
    14     FItems: array of TListItem;
    15     FCount: TListIndex;
    16     function Get(Index: TListIndex): TListItem;
    17     function GetCapacity: TListIndex;
    18     procedure SetCapacity(const AValue: TListIndex);
    19     procedure Put(Index: TListIndex; const AValue: TListItem); virtual;
    20     procedure SetCount(const AValue: TListIndex);
    21     procedure QuickSort(L, R : TListIndex; Compare: TGListSortCompare);
     12    FItems: array of TGListItem;
     13    FCount: TGListIndex;
     14    function Get(Index: TGListIndex): TGListItem;
     15    function GetCapacity: TGListIndex;
     16    procedure SetCapacity(const AValue: TGListIndex);
     17    procedure Put(Index: TGListIndex; const AValue: TGListItem); virtual;
     18    procedure SetCount(const AValue: TGListIndex);
     19    procedure QuickSort(L, R : TGListIndex; Compare: TGListSortCompare);
    2220  public
    2321    // All items
     
    2826    procedure Sort(Compare: TGListSortCompare);
    2927    function Implode(Separator: string; Converter: TGListStringConverter): string;
    30     procedure Perform(Operation: TGListOperation);
    3128    // Many items
    32     procedure MoveItems(CurIndex, NewIndex, Count: TListIndex);
    33     procedure DeleteItems(Index, Count: TListIndex);
    34     procedure Fill(Start, Count: TListIndex; Value: TListItem);
     29    procedure MoveItems(CurIndex, NewIndex, Count: TGListIndex);
     30    procedure DeleteItems(Index, Count: TGListIndex);
     31    procedure Fill(Start, Count: TGListIndex; Value: TGListItem);
    3532    // One item
    36     function Add(Item: TListItem): TListIndex;
    37     procedure Delete(Index: TListIndex); virtual;
    38     function Extract(Item: TListItem): TListItem;
    39     procedure Exchange(Index1, Index2: TListIndex);
    40     function First: TListItem;
    41     function IndexOf(Item: TListItem; Start: TListIndex = 0): TListIndex;
    42     procedure Insert(Index: TListIndex; Item: TListItem);
    43     function Last: TListItem;
    44     procedure Move(CurIndex, NewIndex: TListIndex);
    45     function Remove(Item: TListItem): TListIndex;
    46     property Items[Index: TListIndex]: TListItem read Get write Put; default;
     33    function Add(Item: TGListItem): TGListIndex;
     34    procedure Delete(Index: TGListIndex); virtual;
     35    function Extract(Item: TGListItem): TGListItem;
     36    procedure Exchange(Index1, Index2: TGListIndex);
     37    function First: TGListItem;
     38    function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex;
     39    procedure Insert(Index: TGListIndex; Item: TGListItem);
     40    function Last: TGListItem;
     41    procedure Move(CurIndex, NewIndex: TGListIndex);
     42    function Remove(Item: TGListItem): TGListIndex;
     43    property Items[Index: TGListIndex]: TGListItem read Get write Put; default;
    4744    // List
    4845    procedure AddList(List: TGList);
    4946    procedure Assign(List: TGList);
    5047    function Equals(List: TGList): Boolean;
    51     procedure InsertList(Index: TListIndex; List: TGList);
    52     function IndexOfList(List: TGList; Start: TListIndex = 0): TListIndex;
     48    procedure InsertList(Index: TGListIndex; List: TGList);
     49    function IndexOfList(List: TGList; Start: TGListIndex = 0): TGListIndex;
    5350    // Other
    54     property Count: TListIndex read FCount write SetCount;
    55     property Capacity: TListIndex read GetCapacity write SetCapacity;
     51    property Count: TGListIndex read FCount write SetCount;
     52    property Capacity: TGListIndex read GetCapacity write SetCapacity;
    5653    // Array
    57     procedure AddArray(Values: array of TListItem);
    58     procedure SetArray(Values: array of TListItem);
    59     procedure InsertArray(Index: TListIndex; Values: array of TListItem);
     54    procedure AddArray(Values: array of TGListItem);
     55    procedure SetArray(Values: array of TGListItem);
     56    procedure InsertArray(Index: TGListIndex; Values: array of TGListItem);
    6057  end;
    6158 
     
    6360{$ENDIF}
    6461
    65 {$IFDEF IMPLEMENTATION}
     62{$IFDEF IMPLEMENTATION_USES}
    6663
    6764uses
    6865  RtlConsts;
    6966
     67{$UNDEF IMPLEMENTATION_USES}
     68{$ENDIF}
     69
     70{$IFDEF IMPLEMENTATION}
     71
    7072{ TGList }
    7173
    72 function TGList.GetCapacity: TListIndex;
     74function TGList.GetCapacity: TGListIndex;
    7375begin
    7476  Result := Length(FItems);
    7577end;
    7678
    77 procedure TGList.SetCapacity(const AValue: TListIndex);
     79procedure TGList.SetCapacity(const AValue: TGListIndex);
    7880begin
    7981  SetLength(FItems, AValue);
    8082end;
    8183
    82 function TGList.Get(Index: TListIndex): TListItem;
     84function TGList.Get(Index: TGListIndex): TGListItem;
    8385begin
    8486  Result := FItems[Index];
    8587end;
    8688
    87 procedure TGList.Put(Index: TListIndex; const AValue: TListItem);
     89procedure TGList.Put(Index: TGListIndex; const AValue: TGListItem);
    8890begin
    8991  FItems[Index] := AValue;
    9092end;
    9193
    92 procedure TGList.SetCount(const AValue: TListIndex);
     94procedure TGList.SetCount(const AValue: TGListIndex);
    9395begin
    9496  SetLength(FItems, AValue);
     
    9698end;
    9799
    98 procedure TGList.QuickSort(L, R: TListIndex; Compare: TGListSortCompare);
    99 var
    100   I, J: TListIndex;
    101   P, Q: TListItem;
     100procedure TGList.QuickSort(L, R: TGListIndex; Compare: TGListSortCompare);
     101var
     102  I, J: TGListIndex;
     103  P, Q: TGListItem;
    102104begin
    103105 repeat
     
    139141procedure TGList.Expand;
    140142var
    141   IncSize: TListIndex;
     143  IncSize: TGListIndex;
    142144begin
    143145  if FCount = Capacity then begin
     
    158160end;
    159161
    160 function TGList.Extract(Item: TListItem): TListItem;
    161 var
    162   I: TListIndex;
     162function TGList.Extract(Item: TGListItem): TGListItem;
     163var
     164  I: TGListIndex;
    163165begin
    164166  I := IndexOf(Item);
     
    170172end;
    171173
    172 function TGList.First: TListItem;
     174function TGList.First: TGListItem;
    173175begin
    174176  if FCount = 0 then
     
    178180end;
    179181
    180 function TGList.IndexOf(Item: TListItem; Start: TListIndex): TListIndex;
     182function TGList.IndexOf(Item: TGListItem; Start: TGListIndex): TGListIndex;
    181183begin
    182184  Result := Start;
    183185  while (Result < FCount) and
    184   not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TListItem)) do
     186  not CompareMem(Addr(FItems[Result]), Addr(Item), SizeOf(TGListItem)) do
    185187    Result := Result + 1;
    186188  if Result = FCount then Result := -1;
    187189end;
    188190
    189 procedure TGList.Insert(Index: TListIndex; Item: TListItem);
     191procedure TGList.Insert(Index: TGListIndex; Item: TGListItem);
    190192begin
    191193  if (Index < 0) or (Index > FCount ) then
     
    193195  if FCount = Capacity then Expand;
    194196  if Index < FCount then
    195     System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TListItem));
     197    System.Move(FItems[Index], FItems[Index + 1], (FCount - Index) * SizeOf(TGListItem));
    196198  FItems[Index] := Item;
    197199  FCount := FCount + 1;
    198200end;
    199201
    200 procedure TGList.InsertList(Index: TListIndex; List: TGList);
    201 var
    202   I: TListIndex;
     202procedure TGList.InsertList(Index: TGListIndex; List: TGList);
     203var
     204  I: TGListIndex;
    203205begin
    204206  I := 0;
     
    209211end;
    210212
    211 function TGList.IndexOfList(List: TGList; Start: TListIndex): TListIndex;
    212 var
    213   I: TListIndex;
     213function TGList.IndexOfList(List: TGList; Start: TGListIndex): TGListIndex;
     214var
     215  I: TGListIndex;
    214216begin
    215217  if List.Count > 0 then begin
     
    218220      I := 1;
    219221      while I < List.Count do begin
    220         if not CompareMem(Addr(FItems[Result + I]), Addr(List.FItems[I]), SizeOf(TListItem)) then begin
     222        if not CompareMem(Addr(FItems[Result + I]), Addr(List.FItems[I]), SizeOf(TGListItem)) then begin
    221223          Result := -1;
    222224          Break;
     
    228230end;
    229231
    230 function TGList.Last: TListItem;
     232function TGList.Last: TGListItem;
    231233begin
    232234  if FCount = 0 then
     
    236238end;
    237239
    238 procedure TGList.Move(CurIndex, NewIndex: TListIndex);
    239 var
    240   Temp: TListItem;
     240procedure TGList.Move(CurIndex, NewIndex: TGListIndex);
     241var
     242  Temp: TGListItem;
    241243begin
    242244  if ((CurIndex < 0) or (CurIndex > Count - 1)) then
     
    246248  Temp := FItems[CurIndex];
    247249  if NewIndex > CurIndex then begin
    248     System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(TListItem));
     250    System.Move(FItems[CurIndex + 1], FItems[CurIndex], (NewIndex - CurIndex) * SizeOf(TGListItem));
    249251  end else
    250252  if NewIndex < CurIndex then begin
    251     System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(TListItem));
     253    System.Move(FItems[NewIndex], FItems[NewIndex + 1], (CurIndex - NewIndex) * SizeOf(TGListItem));
    252254  end;
    253255  FItems[NewIndex] := Temp;
     
    256258end;
    257259
    258 procedure TGList.MoveItems(CurIndex, NewIndex, Count: TListIndex);
     260procedure TGList.MoveItems(CurIndex, NewIndex, Count: TGListIndex);
    259261var
    260262  S: Integer;
     
    281283end;
    282284
    283 function TGList.Remove(Item: TListItem): TListIndex;
     285function TGList.Remove(Item: TGListItem): TGListIndex;
    284286begin
    285287  Result := IndexOf(Item);
     
    290292function TGList.Equals(List: TGList): Boolean;
    291293var
    292   I: TListIndex;
     294  I: TGListIndex;
    293295begin
    294296  Result := Count = List.Count;
     
    296298    I := 0;
    297299    while I < Count do begin
    298       if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(TListItem)) then begin
     300      if not CompareMem(Addr(FItems[I]), Addr(List.FItems[I]), SizeOf(TGListItem)) then begin
    299301        Result := False;
    300302        Break;
     
    307309procedure TGList.Reverse;
    308310var
    309   I: TListIndex;
     311  I: TGListIndex;
    310312begin
    311313  I := 0;
     
    322324end;
    323325
    324 procedure TGList.AddArray(Values: array of TListItem);
    325 var
    326   I: TListIndex;
     326procedure TGList.AddArray(Values: array of TGListItem);
     327var
     328  I: TGListIndex;
    327329begin
    328330  I := 0;
     
    333335end;
    334336
    335 procedure TGList.SetArray(Values: array of TListItem);
    336 var
    337   I: TListIndex;
     337procedure TGList.SetArray(Values: array of TGListItem);
     338var
     339  I: TGListIndex;
    338340begin
    339341  Clear;
     
    345347end;
    346348
    347 procedure TGList.InsertArray(Index: TListIndex; Values: array of TListItem);
    348 var
    349   I: TListIndex;
     349procedure TGList.InsertArray(Index: TGListIndex; Values: array of TGListItem);
     350var
     351  I: TGListIndex;
    350352begin
    351353  I := 0;
     
    358360function TGList.Implode(Separator: string; Converter: TGListStringConverter): string;
    359361var
    360   I: TListIndex;
     362  I: TGListIndex;
    361363begin
    362364  Result := '';
     
    370372end;
    371373
    372 procedure TGList.Perform(Operation: TGListOperation);
    373 var
    374   I: TListIndex;
    375 begin
    376   I := 0;
    377   while I < Count do begin
    378     Operation(Self, @FItems[I]);
    379     I := I + 1;
    380   end;
    381 end;
    382 
    383 function TGList.Add(Item: TListItem): TListIndex;
     374function TGList.Add(Item: TGListItem): TGListIndex;
    384375begin
    385376  if FCount = Capacity then
     
    392383procedure TGList.AddList(List: TGList);
    393384var
    394   I: TListIndex;
     385  I: TGListIndex;
    395386begin
    396387  I := 0;
     
    407398end;
    408399
    409 procedure TGList.Delete(Index: TListIndex);
     400procedure TGList.Delete(Index: TGListIndex);
    410401begin
    411402  if (Index < 0) or (Index >= FCount) then
    412403    raise EListError.CreateFmt(SListIndexError, [Index]);
    413404  FCount := FCount - 1;
    414   System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TListItem));
     405  System.Move(FItems[Index + 1], FItems[Index], (FCount - Index) * SizeOf(TGListItem));
    415406  Contract;
    416407end;
    417408
    418 procedure TGList.DeleteItems(Index, Count: TListIndex);
    419 var
    420   I: TListIndex;
     409procedure TGList.DeleteItems(Index, Count: TGListIndex);
     410var
     411  I: TGListIndex;
    421412begin
    422413  I := Index;
     
    427418end;
    428419
    429 procedure TGList.Fill(Start, Count: TListIndex; Value: TListItem);
     420procedure TGList.Fill(Start, Count: TGListIndex; Value: TGListItem);
    430421begin
    431422  while Count > 0 do begin
     
    436427end;
    437428
    438 procedure TGList.Exchange(Index1, Index2: TListIndex);
    439 var
    440   Temp: TListItem;
     429procedure TGList.Exchange(Index1, Index2: TGListIndex);
     430var
     431  Temp: TGListItem;
    441432begin
    442433  if ((Index1 >= FCount) or (Index1 < 0)) then
  • Generics/TemplateGenerics/Generic/GenericObjectList.inc

    r83 r84  
    11{$IFDEF INTERFACE}
    22
    3   TListIndex = TObjectListIndex;
    4   TListItem = TObjectListItem;
    5   {$DEFINE INTERFACE}
    6   {$INCLUDE 'GenericList.inc'}
     3{$DEFINE TGListIndex := TGObjectListIndex}
     4{$DEFINE TGListItem := TGObjectListItem}
     5{$DEFINE TGList := TGObjectListList}
     6{$DEFINE TGListSortCompare := TGObjectListSortCompare}
     7{$DEFINE TGListStringConverter := TObjectListStringConverter}
     8{$DEFINE INTERFACE}
     9{$INCLUDE 'GenericList.inc'}
    710
    811  // TGObjectList<TObjectListIndex, TObjectListItem> = class(TGList)
    912  TGObjectList = class(TGList)
    1013  private
    11     procedure Put(Index: TListIndex; const AValue: TListItem); override;
     14    procedure Put(Index: TGListIndex; const AValue: TGListItem); override;
    1215  public
    1316    OwnsObjects: Boolean;
    14     procedure Delete(Index: TListIndex); override;
     17    procedure Delete(Index: TGObjectListIndex); override;
    1518    procedure Clear; override;
    1619    constructor Create;
     
    2326{$IFDEF IMPLEMENTATION}
    2427
     28{$UNDEF IMPLEMENTATION}
     29{$DEFINE IMPLEMENTATION_USES}
     30{$INCLUDE '..\Generic\GenericList.inc'}
     31
     32{$DEFINE TGListIndex := TGObjectListIndex}
     33{$DEFINE TGListItem := TGObjectListItem}
     34{$DEFINE TGList := TGObjectListList}
     35{$DEFINE TGListSortCompare := TGObjectListSortCompare}
     36{$DEFINE TGListStringConverter := TObjectListStringConverter}
    2537{$DEFINE IMPLEMENTATION}
    2638{$INCLUDE 'GenericList.inc'}
     
    2840{ TGObjectList }
    2941
    30 procedure TGObjectList.Put(Index: TObjectListIndex; const AValue: TObjectListItem);
     42procedure TGObjectList.Put(Index: TGListIndex; const AValue: TGListItem);
    3143begin
    3244  if OwnsObjects then FItems[Index].Free;
     
    3446end;
    3547
    36 procedure TGObjectList.Delete(Index: TObjectListIndex);
     48procedure TGObjectList.Delete(Index: TGObjectListIndex);
    3749begin
    3850  if OwnsObjects then FItems[Index].Free;
     
    4254procedure TGObjectList.Clear;
    4355var
    44   I: TObjectListIndex;
     56  I: TGObjectListIndex;
    4557begin
    4658  if OwnsObjects then begin
     
    6678end;
    6779
     80{$UNDEF IMPLEMENTATION}
    6881{$ENDIF}
  • Generics/TemplateGenerics/Generic/GenericQueue.inc

    r83 r84  
    11{$IFDEF INTERFACE}
    22
    3   TListIndex = TQueueIndex;
    4   TListItem = TQueueItem;
    5   {$DEFINE INTERFACE}
    6   {$INCLUDE 'GenericList.inc'}
     3{$DEFINE TGListIndex := TGQueueIndex}
     4{$DEFINE TGListItem := TGQueueItem}
     5{$DEFINE TGList := TGQueueList}
     6{$DEFINE TGListSortCompare := TGQueueSortCompare}
     7{$DEFINE TGListStringConverter := TGQueueStringConverter}
     8{$DEFINE INTERFACE}
     9{$INCLUDE 'GenericList.inc'}
    710
    811  // TGQueue<TSetIndex, TSetItem> = class(TGList)
     
    1114    FList: TGList;
    1215  public
    13     procedure Enqueue(Value: TQueueItem);
    14     function Dequeue: TQueueItem;
    15     function Peek: TQueueItem;
     16    procedure Enqueue(Value: TGQueueItem);
     17    function Dequeue: TGQueueItem;
     18    function Peek: TGQueueItem;
    1619    constructor Create;
    1720    destructor Destroy; override;
     
    2225{$ENDIF}
    2326
     27{$IFDEF IMPLEMENTATION_USES}
     28
     29  {$DEFINE IMPLEMENTATION_USES}
     30  {$INCLUDE '..\Generic\GenericList.inc'}
     31
     32{$UNDEF IMPLEMENTATION_USES}
     33{$ENDIF}
     34
    2435{$IFDEF IMPLEMENTATION}
    2536
     37{$DEFINE TGListIndex := TGQueueIndex}
     38{$DEFINE TGListItem := TGQueueItem}
     39{$DEFINE TGList := TGQueueList}
     40{$DEFINE TGListSortCompare := TGQueueSortCompare}
     41{$DEFINE TGListStringConverter := TGQueueStringConverter}
    2642{$DEFINE IMPLEMENTATION}
    2743{$INCLUDE 'GenericList.inc'}
     
    2945{ TGQueue }
    3046
    31 procedure TGQueue.Enqueue(Value: TQueueItem);
     47procedure TGQueue.Enqueue(Value: TGQueueItem);
    3248begin
    3349  FList.Add(Value);
    3450end;
    3551
    36 function TGQueue.Peek: TQueueItem;
     52function TGQueue.Peek: TGQueueItem;
    3753begin
    3854  Result := FList.First;
     
    5066end;
    5167
    52 function TGQueue.Dequeue: TQueueItem;
     68function TGQueue.Dequeue: TGQueueItem;
    5369begin
    5470  Result := FList.Extract(FList.First);
    5571end;
    5672
     73{$UNDEF IMPLEMENTATION}
    5774{$ENDIF}
  • Generics/TemplateGenerics/Generic/GenericRange.inc

    r83 r84  
    4141end;
    4242
     43{$UNDEF IMPLEMENTATION}
    4344{$ENDIF}
  • Generics/TemplateGenerics/Generic/GenericSet.inc

    r83 r84  
    11{$IFDEF INTERFACE}
    22
    3   TListIndex = TSetIndex;
    4   TListItem = TSetItem;
    5   {$DEFINE INTERFACE}
    6   {$INCLUDE 'GenericList.inc'}
     3{$DEFINE TGListIndex := TGSetIndex}
     4{$DEFINE TGListItem := TGSetItem}
     5{$DEFINE TGList := TGSetList}
     6{$DEFINE TGListSortCompare := TGSetSortCompare}
     7{$DEFINE TGListStringConverter := TGSetStringConverter}
     8{$DEFINE INTERFACE}
     9{$INCLUDE 'GenericList.inc'}
    710
    8   // TGSet<TSetIndex, TSetItem> = class(TGSet)
     11  // TGSet<TGSetIndex, TGSetItem> = class
    912  TGSet = class
    1013  private
    1114    FList: TGList;
    1215  public
    13     function IsIn(Item: TSetItem): Boolean;
     16    function IsIn(Item: TGSetItem): Boolean;
    1417    constructor Create;
    1518    destructor Destroy; override;
     
    2023{$ENDIF}
    2124
     25{$IFDEF IMPLEMENTATION_USES}
     26
     27  {$DEFINE IMPLEMENTATION_USES}
     28  {$INCLUDE '..\Generic\GenericList.inc'}
     29
     30{$UNDEF IMPLEMENTATION_USES}
     31{$ENDIF}
     32
    2233{$IFDEF IMPLEMENTATION}
    2334
     35{$DEFINE TGListIndex := TGSetIndex}
     36{$DEFINE TGListItem := TGSetItem}
     37{$DEFINE TGList := TGSetList}
     38{$DEFINE TGListSortCompare := TGSetSortCompare}
     39{$DEFINE TGListStringConverter := TGSetStringConverter}
    2440{$DEFINE IMPLEMENTATION}
    2541{$INCLUDE 'GenericList.inc'}
     
    2743{ TGSet }
    2844
    29 function TGSet.IsIn(Item: TSetItem): Boolean;
     45function TGSet.IsIn(Item: TGSetItem): Boolean;
    3046begin
    3147  Result := FList.IndexOf(Item) <> -1;
     
    4359end;
    4460
     61{$UNDEF IMPLEMENTATION}
    4562{$ENDIF}
  • Generics/TemplateGenerics/Generic/GenericStack.inc

    r83 r84  
    11{$IFDEF INTERFACE}
    22
    3   TListIndex = TStackIndex;
    4   TListItem = TStackItem;
    5   {$DEFINE INTERFACE}
    6   {$INCLUDE 'GenericList.inc'}
     3{$DEFINE TGListIndex := TGStackIndex}
     4{$DEFINE TGListItem := TGStackItem}
     5{$DEFINE TGList := TGStackList}
     6{$DEFINE TGListSortCompare := TGStackSortCompare}
     7{$DEFINE TGListStringConverter := TGStackStringConverter}
     8{$DEFINE INTERFACE}
     9{$INCLUDE 'GenericList.inc'}
    710
    811  // TGStack<TStackIndex, TStackItem> = class(TGList)
     
    1114    FList: TGList;
    1215  public
    13     procedure Push(Value: TStackItem);
    14     function Pop: TStackItem;
     16    procedure Push(Value: TGStackItem);
     17    function Pop: TGStackItem;
    1518    constructor Create;
    1619    destructor Destroy; override;
     
    2124{$ENDIF}
    2225
     26{$IFDEF IMPLEMENTATION_USES}
     27
     28  {$DEFINE IMPLEMENTATION_USES}
     29  {$INCLUDE '..\Generic\GenericList.inc'}
     30
     31{$UNDEF IMPLEMENTATION_USES}
     32{$ENDIF}
     33
    2334{$IFDEF IMPLEMENTATION}
    2435
     36{$DEFINE TGListIndex := TGStackIndex}
     37{$DEFINE TGListItem := TGStackItem}
     38{$DEFINE TGList := TGStackList}
     39{$DEFINE TGListSortCompare := TGStackSortCompare}
     40{$DEFINE TGListStringConverter := TGStackStringConverter}
    2541{$DEFINE IMPLEMENTATION}
    2642{$INCLUDE 'GenericList.inc'}
     
    2844{ TGStack }
    2945
    30 procedure TGStack.Push(Value: TStackItem);
     46procedure TGStack.Push(Value: TGStackItem);
    3147begin
    3248  FList.Add(Value);
    3349end;
    3450
    35 function TGStack.Pop: TStackItem;
     51function TGStack.Pop: TGStackItem;
    3652begin
    3753  Result := FList.Extract(FList.Last);
     
    4965end;
    5066
     67{$UNDEF IMPLEMENTATION}
    5168{$ENDIF}
  • Generics/TemplateGenerics/Generic/GenericTree.inc

    r83 r84  
    33  TGTreeNode = class;
    44
    5   TListIndex = TTreeIndex;
    6   TListItem = TGTreeNode;
    7   {$DEFINE INTERFACE}
    8   {$INCLUDE 'GenericList.inc'}
     5{$DEFINE TGListIndex := TGTreeIndex}
     6{$DEFINE TGListItem := TGTreeNode}
     7{$DEFINE TGList := TGTreeNodeList}
     8{$DEFINE TGListSortCompare := TGTreeSortCompare}
     9{$DEFINE TGListStringConverter := TGTreeStringConverter}
     10{$DEFINE INTERFACE}
     11{$INCLUDE 'GenericList.inc'}
    912
    10   TTreeNodeList = class(TGList)
    11   end;
    12 
    13   // TGTreeNode<TTreeIndex, TTreeItem> = class
     13  // TGTreeNode<TGTreeIndex, TGTreeItem> = class
    1414  TGTreeNode = class
    15     Childs: TTreeNodeList;
    16     Value: TTreeItem;
     15    Childs: TGTreeNodeList;
     16    Value: TGTreeItem;
    1717    procedure Clear;
    1818  end;
    1919
    20   // TGTree<TTreeIndex, TTreeItem> = class
     20  // TGTree<TGTreeIndex, TGTreeItem> = class
    2121  TGTree = class
    2222    TopItem: TGTreeNode;
     
    2727{$ENDIF}
    2828
     29{$IFDEF IMPLEMENTATION_USES}
     30
     31  {$DEFINE IMPLEMENTATION_USES}
     32  {$INCLUDE 'GenericList.inc'}
     33
     34{$UNDEF INTERFACE_USES}
     35{$ENDIF}
     36
     37
    2938{$IFDEF IMPLEMENTATION}
     39{$UNDEF IMPLEMENTATION}
    3040
     41{$DEFINE TGListIndex := TGTreeIndex}
     42{$DEFINE TGListItem := TGTreeNode}
     43{$DEFINE TGList := TGTreeNodeList}
     44{$DEFINE TGListSortCompare := TGTreeSortCompare}
     45{$DEFINE TGListStringConverter := TGTreeStringConverter}
    3146{$DEFINE IMPLEMENTATION}
    3247{$INCLUDE 'GenericList.inc'}
     
    4661end;
    4762
     63{$UNDEF IMPLEMENTATION}
    4864{$ENDIF}
Note: See TracChangeset for help on using the changeset viewer.