aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/csharp/runtime/java/util/Arrays.cs
blob: 683358255ddbae619b3bb33c74e90dc9c7c5c1d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace Couscous.java.util {
    internal static class Arrays {
        internal static java.lang.Iterable<T> asList<T>(T[] values) {
            return new _ArrayList<T>(values);
        }
    }
    
    internal class _ArrayList<T> : java.lang.Iterable<T> {
        private readonly T[] values;
        
        internal _ArrayList(T[] values) {
            this.values = values;
        }
        
        public java.lang.Iterator<T> iterator() {
            return new _ArrayIterator<T>(values);
        }
    }
    
    internal class _ArrayIterator<T> : java.lang.Iterator<T> {
        private readonly T[] values;
        private int nextIndex;
        
        internal _ArrayIterator(T[] values) {
            this.values = values;
            this.nextIndex = 0;
        }
        
        public bool hasNext() {
            return nextIndex < values.Length;
        }
        
        public T next() {
            return values[nextIndex++];
        }
    }
}