source: Generics/NativeGenerics/Generic/GenericStack.pas

Last change on this file was 496, checked in by chronos, 6 years ago
  • Modified: New native generics classes working under FPC 3.0 transformed from TemplateGenerics package.
File size: 674 bytes
Line 
1unit GenericStack;
2
3{$mode delphi}
4
5interface
6
7uses
8 GenericList;
9
10type
11 TGStack<T> = class
12 private
13 FList: TGList<T>;
14 public
15 procedure Push(Value: T);
16 function Pop: T;
17 constructor Create;
18 destructor Destroy; override;
19 property List: TGList<T> read FList;
20 end;
21
22
23implementation
24
25{ TGStack }
26
27procedure TGStack<T>.Push(Value: T);
28begin
29 FList.Add(Value);
30end;
31
32function TGStack<T>.Pop: T;
33begin
34 Result := FList.Extract(FList.Last);
35end;
36
37constructor TGStack<T>.Create;
38begin
39 FList := TGList<T>.Create;
40end;
41
42destructor TGStack<T>.Destroy;
43begin
44 FList.Free;
45 inherited Destroy;
46end;
47
48end.
Note: See TracBrowser for help on using the repository browser.