标签:
function Queue() {
var items = [];
this.enqueue = function(element) {
items.push(element)
}
this.dequeue = function(element) {
items.shift()
}
this.front = function() {
return items[0]
}
this.isEmpty = function() {
return items.length == 0
}
this.size = function() {
return items.length
}
this.printf = function() {
console.log(items.toString())
}
this.print = function() {
console.log(items.toString())
}
}
var queue = new Queue();
console.log(queue.isEmpty());
queue.enqueue(‘shidengyun‘);
queue.enqueue(‘zhujing‘);
queue.print();
console.log(queue.size());
console.log(queue.isEmpty());
queue.dequeue();
queue.print();
javaScript Queue
标签:
原文地址:http://www.cnblogs.com/shidengyun/p/5125777.html