4
using System.Collections.Generic;
6
internal class EnumeratorWrapper<T> : Iterator<T>
14
public EnumeratorWrapper (object collection, IEnumerator<T> e)
17
this.collection = collection;
18
this.more = e.MoveNext ();
21
public override bool HasNext ()
26
public override T Next ()
29
throw new NoSuchElementException ();
35
public override void Remove ()
37
ICollection<T> col = this.collection as ICollection<T>;
39
throw new NotSupportedException ();
41
if (more && !copied) {
42
// Read the remaining elements, since the current enumerator
43
// will be invalid after removing the element
44
List<T> remaining = new List<T> ();
46
remaining.Add (e.Current);
47
} while (e.MoveNext ());
48
e = remaining.GetEnumerator ();