Skip to content

Instantly share code, notes, and snippets.

@codeimpossible
Created September 26, 2012 01:56
Show Gist options
  • Save codeimpossible/3785559 to your computer and use it in GitHub Desktop.
Save codeimpossible/3785559 to your computer and use it in GitHub Desktop.
simple queue data structure
var queue = new (function(undefined){
var _q = [], _size = 0;
this.push = function(task) {
_q.push(task);
_size++;
return task;
};
this.next = function() {
_size--;
return _q.shift();
};
this.peek = function() {
return _q[0] || undefined;
};
this.getLength = function() {
return _size;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment