Skip to main content
Code Review

Return to Revisions

3 of 3
Commonmark migration

Bug

There's a bug in your Reset method.

public void Reset()
{
 _current = null;
}

It should also be resetting the Q and not only the _current field. With the current Reset you can call MoveNext and continue where you left. The very first call to MoveNext should execute Q.Enqueue(_tree); and not the constructor. This is, when _current is null.

Altenatively you can throw an exception:

The Reset method is provided for COM interoperability and does not need to be fully implemented; instead, the implementer can throw a NotSupportedException.

IEnumerator Interface

Personally I don't like this convention because it means you have to reinstantiate the enumerator. It's much better to actually implement the Reset correctly... if posssible.

t3chb0t
  • 44.6k
  • 9
  • 84
  • 190
default

AltStyle によって変換されたページ (->オリジナル) /