数据结构 - 队列
var Queue = function() {
this.data = [];
}
Queue.prototype.enqueue = function(element) {
this.data.push(element);
}
Queue.prototype.dequeue = function() {
return this.data.shift();
}
Queue.prototype.peek = function() {
return this.data[0];
}
Queue.prototype.print = function() {
return this.data.join('\n');
}
Queue.prototype.isEmpty = function() {
return this.data.length === 0;
}
Queue.prototype.getLength = function() {
return this.data.length;
}
var myQueue = new Queue();
本文标题:数据结构 - 队列
本文链接:https://www.haomeiwen.com/subject/ggwwnttx.html
网友评论