队列结构
function Queue() {
this.items = [];
if (typeof this.enqueue != 'function') {
Queue.prototype.enqueue = function(element) {
this.items.push(element);
};
Queue.prototype.dequeue = function(element) {
return this.items.shift();
};
Queue.prototype.front = function(element) {
return this.items[0];
};
Queue.prototype.isEmpty = function(element) {
return this.length == 0;
};
Queue.prototype.size = function(element) {
return this.items.length;
};
Queue.prototype.clear = function(element) {
this.items = [];
};
Queue.prototype.print = function(element) {
console.log(this.items.toString());
};
}
}