-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.inc_pas
130 lines (104 loc) · 2.9 KB
/
Stack.inc_pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
(*
* DGL(The Delphi Generic Library)
*
* Copyright (c) 2004
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*)
//------------------------------------------------------------------------------
// _TStackµÄʵÏÖ
// Create by HouSisong, 2004.09.08
//------------------------------------------------------------------------------
{$ifndef __Stack_inc_pas_}
{$define __Stack_inc_pas_}
{$I DGLIntf.inc_pas}
{$I Deque.inc_pas}
{ _TStack }
procedure _TStack.Assign(const ItBegin, ItEnd: _IIterator);
begin
self.FBaseContainer.Assign(ItBegin, ItEnd);
end;
procedure _TStack.Assign(const num: integer; const Value: _ValueType);
begin
self.FBaseContainer.Assign(num,Value);
end;
procedure _TStack.Clear;
begin
FBaseContainer.Clear();
end;
function _TStack.Clone: _IStack;
begin
result:=_TStack.Create(self);
end;
constructor _TStack.Create;
begin
inherited Create();
FBaseContainer :=_TDefaultStackBaseContainer.Create();
end;
constructor _TStack.Create(const num: integer; const Value: _ValueType);
begin
inherited Create();
FBaseContainer :=_TDefaultStackBaseContainer.Create(num,Value);
end;
constructor _TStack.Create(const num: integer);
begin
inherited Create();
FBaseContainer :=_TDefaultStackBaseContainer.Create(num);
end;
constructor _TStack.Create(const AStack: _TStack);
begin
inherited Create();
FBaseContainer :=_TDefaultStackBaseContainer.Create(AStack.FBaseContainer as _TDefaultStackBaseContainer);
end;
constructor _TStack.Create(const ItBegin, ItEnd: _IIterator);
begin
inherited Create();
FBaseContainer :=_TDefaultStackBaseContainer.Create(ItBegin, ItEnd);
end;
destructor _TStack.Destroy;
begin
FBaseContainer.Free();
inherited;
end;
function _TStack.GetSelfObj: TObject;
begin
result:=self;
end;
function _TStack.IsEmpty: Boolean;
begin
result:=FBaseContainer.IsEmpty;
end;
function _TStack.IsEquals(const AContainer: _IStack): Boolean;
begin
result:=FBaseContainer.IsEquals((AContainer.GetSelfObj as _TStack).FBaseContainer as _TDefaultStackBaseContainer);
end;
procedure _TStack.Pop;
begin
FBaseContainer.PopBack();
end;
procedure _TStack.Push(const Value: _ValueType);
begin
FBaseContainer.PushBack(Value);
end;
function _TStack.Size: Integer;
begin
result:=FBaseContainer.Size;
end;
function _TStack.GetTopValue: _ValueType;
begin
result:=FBaseContainer.GetBackValue();
end;
procedure _TStack.SetTopValue(const aValue:_ValueType);
begin
FBaseContainer.SetBackValue(aValue);
end;
{$endif } // __Stack_inc_pas_