算法:基於 RingBuffer 的 Queue 實現《續》

背景 上篇實現了一個簡單的隊列,內部使用了 _count 計數,本文采用另外一種模式,不用 _count 計數。 RingBuffer 不用 _count 計數的話,爲了區分隊列的滿和空,需要在數組中預留一格,如下圖就代表了一個滿隊列。 ArrayQueue 代碼 1 using System; 2 using System.Collections.Generic; 3 using Syst
相關文章
相關標籤/搜索