source: trunk/Packages/TemplateGenerics/Generic/GenericStack.inc

Last change on this file was 18, checked in by chronos, 12 years ago
  • Used external packages are now stored in uncompressed form rather in zipped files. This allow better package version synchronisation.
File size: 1.6 KB
Line 
1{$IFDEF INTERFACE}
2
3{$DEFINE TGListIndex := TGStackIndex}
4{$DEFINE TGListItem := TGStackItem}
5{$DEFINE TGList := TGStackList}
6{$DEFINE TGListSortCompare := TGStackSortCompare}
7{$DEFINE TGListToStringConverter := TGStackToStringConverter}
8{$DEFINE TGListFromStringConverter := TGStackFromStringConverter}
9{$DEFINE TGListItemArray := TGStackItemArray}
10{$DEFINE INTERFACE}
11{$I 'GenericList.inc'}
12
13 // TGStack<TStackIndex, TStackItem> = class(TGList)
14 TGStack = class
15 private
16 FList: TGList;
17 public
18 procedure Push(Value: TGStackItem);
19 function Pop: TGStackItem;
20 constructor Create;
21 destructor Destroy; override;
22 property List: TGList read FList;
23 end;
24
25{$UNDEF INTERFACE}
26{$ENDIF}
27
28{$IFDEF IMPLEMENTATION_USES}
29
30 {$DEFINE IMPLEMENTATION_USES}
31 {$I 'GenericList.inc'}
32
33{$UNDEF IMPLEMENTATION_USES}
34{$ENDIF}
35
36{$IFDEF IMPLEMENTATION}
37
38{$DEFINE TGListIndex := TGStackIndex}
39{$DEFINE TGListItem := TGStackItem}
40{$DEFINE TGList := TGStackList}
41{$DEFINE TGListSortCompare := TGStackSortCompare}
42{$DEFINE TGListToStringConverter := TGStackToStringConverter}
43{$DEFINE TGListFromStringConverter := TGStackFromStringConverter}
44{$DEFINE TGListItemArray := TGStackItemArray}
45{$DEFINE IMPLEMENTATION}
46{$I 'GenericList.inc'}
47
48{ TGStack }
49
50procedure TGStack.Push(Value: TGStackItem);
51begin
52 FList.Add(Value);
53end;
54
55function TGStack.Pop: TGStackItem;
56begin
57 Result := FList.Extract(FList.Last);
58end;
59
60constructor TGStack.Create;
61begin
62 FList := TGList.Create;
63end;
64
65destructor TGStack.Destroy;
66begin
67 FList.Free;
68 inherited Destroy;
69end;
70
71{$UNDEF IMPLEMENTATION}
72{$ENDIF}
Note: See TracBrowser for help on using the repository browser.