Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Queue(){
- var head = null;
- var curr = null;
- this.empty = function(){ if (head === null) return true; else return false;}
- this.push = function(val){
- if (head === null){
- head = { value : val, next : null };
- curr = head;
- } else {
- curr.next = { value : val, next : null };
- var tmp = curr.next;
- curr = tmp;
- }
- }
- this.top = function(){
- if (head === null ) return null;
- else return head.value;
- }
- this.pop = function(){
- if(head !== null){
- head = head.next;
- } else {
- curr = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement