diff options
| author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-04-10 19:20:48 +0000 |
|---|---|---|
| committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-04-10 19:20:48 +0000 |
| commit | 160cc1e115eeb75638dce6effdd16b2bc810ddb4 (patch) | |
| tree | b791a95695a7cf674e61a6153139c6f9c6c491fa /packages/fcl-stl/src/gstack.pp | |
| parent | 3843727e74b31bbf2a34e7e3b89ee422269f770e (diff) | |
| parent | 413a6aa6469e6c297780217a27ca91363c637944 (diff) | |
| download | fpc-avr.tar.gz | |
* rebase to trunk@17295avr
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/avr@17296 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-stl/src/gstack.pp')
| -rw-r--r-- | packages/fcl-stl/src/gstack.pp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/packages/fcl-stl/src/gstack.pp b/packages/fcl-stl/src/gstack.pp new file mode 100644 index 0000000000..2d5cfe4020 --- /dev/null +++ b/packages/fcl-stl/src/gstack.pp @@ -0,0 +1,73 @@ +{ + This file is part of the Free Pascal FCL library. + BSD parts (c) 2011 Vlado Boza + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY;without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +**********************************************************************} +{$mode objfpc} + +unit gstack; + +interface + +uses gvector; + +type + generic TStack<T>=class + private + type TContainer= specialize TVector<T>; + var FData:TContainer; + public + procedure Push(x:T);inline; + procedure Pop();inline; + function Top():T;inline; + function Size():longint;inline; + function IsEmpty():boolean;inline; + constructor Create; + destructor Destroy;override; +end; + +implementation + +constructor TStack.Create; +begin + FData:=TContainer.Create; +end; + +destructor TStack.Destroy; +begin + FData.Destroy; +end; + +procedure TStack.Push(x:T);inline; +begin + FData.PushBack(x); +end; + +procedure TStack.Pop;inline; +begin + FData.PopBack; +end; + +function TStack.Top:T;inline; +begin + Top:=FData.Back; +end; + +function TStack.Size:longint;inline; +begin + Size:=FData.Size; +end; + +function TStack.IsEmpty:boolean;inline; +begin + IsEmpty:=FData.IsEmpty; +end; + +end. |
