aalhour / aalhour/C-Sharp-Algorithms

Enumerating the circular buffer does not produce anything

オープン
#155 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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 ','

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

おそらく DataStructures フォルダーにある CircularBuffer クラスを確認してください。問題は、項目を追加した後に列挙 (foreach) が機能しないことです。GetEnumerator メソッドと、バッファーが項目をどのように追跡しているかを確認してください。提供されたサンプルコードを使って問題を再現するテストを書き、その後、列挙ロジックを修正してください。

索引モデルが issue の本文から書いたものです。

評価

issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
65/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。