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

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