summaryrefslogtreecommitdiff
path: root/Queue.js
diff options
context:
space:
mode:
Diffstat (limited to 'Queue.js')
-rwxr-xr-xQueue.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/Queue.js b/Queue.js
new file mode 100755
index 0000000..075a103
--- /dev/null
+++ b/Queue.js
@@ -0,0 +1,2 @@
+//code.stephenmorley.org
+function Queue(){var a=[],b=0;this.getLength=function(){return a.length-b};this.isEmpty=function(){return 0==a.length};this.enqueue=function(b){a.push(b)};this.dequeue=function(){if(0!=a.length){var c=a[b];2*++b>=a.length&&(a=a.slice(b),b=0);return c}};this.peek=function(){return 0<a.length?a[b]:void 0}}; \ No newline at end of file