diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-07-10 17:04:29 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-07-10 17:04:29 -0400 |
| commit | 1de5f9ac6f038bfed2230cc1272b253794b2f41a (patch) | |
| tree | 15bc9d515f1f48c036522afb7cc71f60243849a9 /gamemode/shared/lockbox/queue.lua | |
| download | artery-1de5f9ac6f038bfed2230cc1272b253794b2f41a.tar.gz artery-1de5f9ac6f038bfed2230cc1272b253794b2f41a.tar.bz2 artery-1de5f9ac6f038bfed2230cc1272b253794b2f41a.zip | |
Initial commit
Diffstat (limited to 'gamemode/shared/lockbox/queue.lua')
| -rw-r--r-- | gamemode/shared/lockbox/queue.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gamemode/shared/lockbox/queue.lua b/gamemode/shared/lockbox/queue.lua new file mode 100644 index 0000000..55b067d --- /dev/null +++ b/gamemode/shared/lockbox/queue.lua @@ -0,0 +1,47 @@ +local Queue = function() + local queue = {}; + local tail = 0; + local head = 0; + + local public = {}; + + public.push = function(obj) + queue[head] = obj; + head = head + 1; + return; + end + + public.pop = function() + if tail < head + then + local obj = queue[tail]; + queue[tail] = nil; + tail = tail + 1; + return obj; + else + return nil; + end + end + + public.size = function() + return head - tail; + end + + public.getHead = function() + return head; + end + + public.getTail = function() + return tail; + end + + public.reset = function() + queue = {}; + head = 0; + tail = 0; + end + + return public; +end + +return Queue; |
