佇列

出自ProgWiki
跳至導覽 跳至搜尋

佇列(Queue),參照:『維基百科~Queue_(data_structure)

特性

應用

.NET

C++/STL

C++/Template

Java

JavaScript

function Queue() {
   this.elements = [];
}
 
Queue.prototype.enqueue = function (e) {
   this.elements.push(e);
};
 
Queue.prototype.dequeue = function () {
    return this.elements.shift();
};
 
Queue.prototype.isEmpty = function () {
    return this.elements.length == 0;
};
 
Queue.prototype.peek = function () {
    return !this.isEmpty() ? this.elements[0] : undefined;
};
 
Queue.prototype.length = function() {
    return this.elements.length;
}

Lua

Python

Tcl

VB6

VBA