佇列
跳至導覽
跳至搜尋
佇列(Queue),參照:『維基百科~Queue_(data_structure)』
特性
- 先入先出,FIFO(First In, First Out),參照:『維基百科~FIFO_(computing)』
應用
.NET
- Queue<T> 類別 (System.Collections.Generic) | Microsoft Docs
- Queue 類別 (System.Collections) | Microsoft Docs
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; }