aalhour / aalhour/C-Sharp-Algorithms
Enumerating the circular buffer does not produce anything
- 主要語言
- C#
- 星號
- 6.2k
- 分支
- 1.4k
- PR 合併指標
- 30 天內沒有已合併 PR
描述
After adding some random items to the circular buffer, using foreach or any function to enumerate the buffer does not produce anything
Here is a sample code:
`int[] values = new int[20];
Random rnd = new Random();
for (int i = 0; i < values.Length; i++)
values[i] = rnd.Next(1, 99);
CircularBuffer buffer = new CircularBuffer(values.Length / 2);
Console.WriteLine(string.Join(", ", values));
foreach (int value in values)
buffer.Add(value);
Console.WriteLine(string.Join(", ", buffer));
Console.ReadKey();`
**Expected behavior**
2 lines should be printed: 1 for the array content joined by ',' and another line for the content of the buffer joined by ','
貢獻指南
研究方向
查看 CircularBuffer 類別,它可能位於 DataStructures 資料夾中。問題在於新增項目後列舉 (foreach) 無法正常運作。檢查 GetEnumerator 方法,以及緩衝區如何追蹤項目。使用提供的範例程式碼撰寫測試以重現該問題,然後修正列舉邏輯。
由索引模型根據 Issue 內容生成。
評估
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 65/100