@@ -21,49 +21,49 @@ package kotlin.jvm.internal
21
21
private class ArrayByteIterator (private val array : ByteArray ) : ByteIterator() {
22
22
private var index = 0
23
23
override fun hasNext () = index < array.size
24
- override fun nextByte () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
24
+ override fun nextByte () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
25
25
}
26
26
27
27
private class ArrayCharIterator (private val array : CharArray ) : CharIterator() {
28
28
private var index = 0
29
29
override fun hasNext () = index < array.size
30
- override fun nextChar () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
30
+ override fun nextChar () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
31
31
}
32
32
33
33
private class ArrayShortIterator (private val array : ShortArray ) : ShortIterator() {
34
34
private var index = 0
35
35
override fun hasNext () = index < array.size
36
- override fun nextShort () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
36
+ override fun nextShort () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
37
37
}
38
38
39
39
private class ArrayIntIterator (private val array : IntArray ) : IntIterator() {
40
40
private var index = 0
41
41
override fun hasNext () = index < array.size
42
- override fun nextInt () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
42
+ override fun nextInt () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
43
43
}
44
44
45
45
private class ArrayLongIterator (private val array : LongArray ) : LongIterator() {
46
46
private var index = 0
47
47
override fun hasNext () = index < array.size
48
- override fun nextLong () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
48
+ override fun nextLong () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
49
49
}
50
50
51
51
private class ArrayFloatIterator (private val array : FloatArray ) : FloatIterator() {
52
52
private var index = 0
53
53
override fun hasNext () = index < array.size
54
- override fun nextFloat () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
54
+ override fun nextFloat () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
55
55
}
56
56
57
57
private class ArrayDoubleIterator (private val array : DoubleArray ) : DoubleIterator() {
58
58
private var index = 0
59
59
override fun hasNext () = index < array.size
60
- override fun nextDouble () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
60
+ override fun nextDouble () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
61
61
}
62
62
63
63
private class ArrayBooleanIterator (private val array : BooleanArray ) : BooleanIterator() {
64
64
private var index = 0
65
65
override fun hasNext () = index < array.size
66
- override fun nextBoolean () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { throw NoSuchElementException (e.message) }
66
+ override fun nextBoolean () = try { array[index++ ] } catch (e: ArrayIndexOutOfBoundsException ) { index - = 1 ; throw NoSuchElementException (e.message) }
67
67
}
68
68
69
69
public fun iterator (array : ByteArray ): ByteIterator = ArrayByteIterator (array)
0 commit comments