IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IteratorExtensions.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
3namespace java.util
4{
5
9 public static class IteratorExtensions
10 {
11
18 public static IEnumerator<T> AsEnumerator<T>(this Iterator iterator) => iterator switch
19 {
20 IEnumerator<T> i => i,
21 Iterator i => new IteratorWrapper<T>(i),
22 };
23
30 public static List<T> RemainingToList<T>(this Iterator iterator)
31 {
32 var l = new List<T>();
33 while (iterator.hasNext())
34 l.Add((T)iterator.next());
35
36 return l;
37 }
38
45 public static IEnumerable<T> RemainingToEnumerable<T>(this Iterator iterator)
46 {
47 while (iterator.hasNext())
48 yield return (T)iterator.next();
49 }
50
51 }
52
53}
Provides extension methods for working against Java Iterator instances.
static IEnumerable< T > RemainingToEnumerable< T >(this Iterator iterator)
Returns an enumerable that iterators over the items in an iterator.
static List< T > RemainingToList< T >(this Iterator iterator)
Iterators over the items in an iterator and produces an array.
static IEnumerator< T > AsEnumerator< T >(this Iterator iterator)
Returns the appropriate wrapper type for the given Iterator.