summaryrefslogtreecommitdiff
path: root/packages/fcl-stl/src/gqueue.pp
diff options
context:
space:
mode:
Diffstat (limited to 'packages/fcl-stl/src/gqueue.pp')
-rw-r--r--packages/fcl-stl/src/gqueue.pp75
1 files changed, 75 insertions, 0 deletions
diff --git a/packages/fcl-stl/src/gqueue.pp b/packages/fcl-stl/src/gqueue.pp
new file mode 100644
index 0000000000..a56aef4e47
--- /dev/null
+++ b/packages/fcl-stl/src/gqueue.pp
@@ -0,0 +1,75 @@
+{
+ 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 gqueue;
+
+interface
+
+uses gdeque;
+
+type
+ generic TQueue<T>=class
+ private
+ type
+ TContainer = specialize TDeque<T>;
+ var
+ FData:TContainer;
+ public
+ procedure Push(value:T);inline;
+ procedure Pop();inline;
+ function Front():T;inline;
+ function Size():SizeUInt;inline;
+ function IsEmpty():boolean;inline;
+ constructor Create;
+ destructor Destroy;override;
+end;
+
+implementation
+
+constructor TQueue.Create;
+begin
+ FData:=TContainer.Create;
+end;
+
+destructor TQueue.Destroy;
+begin
+ FData.Destroy;
+end;
+
+procedure TQueue.Push(value:T);inline;
+begin
+ FData.PushBack(value);
+end;
+
+procedure TQueue.Pop();inline;
+begin
+ FData.PopFront;
+end;
+
+function TQueue.Front:T;inline;
+begin
+ Front:=FData.Front;
+end;
+
+function TQueue.Size:SizeUInt;inline;
+begin
+ Size:=FData.Size;
+end;
+
+function TQueue.IsEmpty:boolean;inline;
+begin
+ IsEmpty:=FData.IsEmpty;
+end;
+
+end.