IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IteratorWrapper.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4
5namespace java.util
6{
7
8 class IteratorWrapper<T> : IEnumerator<T>
9 {
10
11 readonly Iterator _iterator;
12 T? _current;
13 int _position = -1;
14
20 public IteratorWrapper(Iterator iterator)
21 {
22 _iterator = iterator ?? throw new ArgumentNullException(nameof(iterator));
23 }
24
28 public T Current => _position > -1 ? _current! : throw new InvalidOperationException();
29
33 object? IEnumerator.Current => _current;
34
39 public bool MoveNext()
40 {
41 if (_iterator.hasNext())
42 {
43 _current = (T)_iterator.next();
44 _position++;
45 return true;
46 }
47
48 return false;
49 }
50
54 public void Dispose()
55 {
56
57 }
58
63 public void Reset()
64 {
65 throw new NotSupportedException();
66 }
67
68 }
69
70}
void Reset()
Not supported.
T Current
Gets the current element.
IteratorWrapper(Iterator iterator)
Initializes a new instance.
void Dispose()
Disposes of the instance.
bool MoveNext()
Moves to the next instance.