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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.