IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
EnumerationWrapper.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 EnumerationWrapper<T> : IEnumerator<T>
9 {
10
11 readonly Enumeration _enumeration;
12 T? _current;
13 int _position = -1;
14
20 public EnumerationWrapper(Enumeration enumeration)
21 {
22 _enumeration = enumeration ?? throw new ArgumentNullException(nameof(enumeration));
23 }
24
28 public T Current => _position > -1 ? _current! : throw new InvalidOperationException();
29
33 object? IEnumerator.Current => _current;
34
40 public bool MoveNext()
41 {
42 if (_enumeration.hasMoreElements())
43 {
44 _current = (T)_enumeration.nextElement();
45 _position++;
46 return true;
47 }
48
49 return false;
50 }
51
55 public void Dispose()
56 {
57
58 }
59
64 public void Reset()
65 {
66 throw new NotSupportedException();
67 }
68
69 }
70
71}
void Dispose()
Disposes of the instance.
bool MoveNext()
Moves to the next instance.
T Current
Gets the current element.
EnumerationWrapper(Enumeration enumeration)
Initializes a new instance.