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