Skip to content

Commit 4c5f0a1

Browse files
committed
Moved Iterator and String steppers to their own files.
1 parent 2674205 commit 4c5f0a1

File tree

3 files changed

+65
-49
lines changed

3 files changed

+65
-49
lines changed

src/main/scala/scala/compat/java8/StepConverters.scala

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ import scala.compat.java8.runtime._
88
package converterImpls {
99
import Stepper._
1010

11-
private[java8] class StepsAnyIterator[A](_underlying: Iterator[A])
12-
extends StepsLikeIterator[A, StepsAnyIterator[A]](_underlying) {
13-
def semiclone() = new StepsAnyIterator(null)
14-
def next() = if (proxied ne null) proxied.nextStep else underlying.next
15-
}
16-
17-
private[java8] class StepsDoubleIterator(_underlying: Iterator[Double])
18-
extends StepsDoubleLikeIterator[StepsDoubleIterator](_underlying) {
19-
def semiclone() = new StepsDoubleIterator(null)
20-
def nextDouble() = if (proxied ne null) proxied.nextStep else underlying.next
21-
}
22-
23-
private[java8] class StepsIntIterator(_underlying: Iterator[Int])
24-
extends StepsIntLikeIterator[StepsIntIterator](_underlying) {
25-
def semiclone() = new StepsIntIterator(null)
26-
def nextInt() = if (proxied ne null) proxied.nextStep else underlying.next
27-
}
28-
29-
private[java8] class StepsLongIterator(_underlying: Iterator[Long])
30-
extends StepsLongLikeIterator[StepsLongIterator](_underlying) {
31-
def semiclone() = new StepsLongIterator(null)
32-
def nextLong() = if (proxied ne null) proxied.nextStep else underlying.next
33-
}
34-
35-
3611
final class RichArrayAnyCanStep[A](private val underlying: Array[A]) extends AnyVal with MakesAnyStepper[A] {
3712
@inline def stepper: AnyStepper[A] with EfficientSubstep = new StepsAnyArray[A](underlying, 0, underlying.length)
3813
}
@@ -311,30 +286,6 @@ package converterImpls {
311286
def reflectInternalsN(bsn: collection.immutable.BitSet.BitSetN): Array[Long] = reflector.invoke(bsn).asInstanceOf[Array[Long]]
312287
}
313288

314-
private[java8] class StepperStringCodePoint(underlying: String, var i0: Int, var iN: Int) extends IntStepper with EfficientSubstep {
315-
def characteristics() = NonNull
316-
def estimateSize = iN - i0
317-
def hasNext = i0 < iN
318-
def nextInt() = {
319-
if (hasNext()) {
320-
val cp = underlying.codePointAt(i0)
321-
i0 += java.lang.Character.charCount(cp)
322-
cp
323-
}
324-
else throwNSEE
325-
}
326-
def substep() = {
327-
if (iN-3 > i0) {
328-
var half = (i0+iN) >>> 1
329-
if (java.lang.Character.isLowSurrogate(underlying.charAt(half))) half -= 1
330-
val ans = new StepperStringCodePoint(underlying, i0, half)
331-
i0 = half
332-
ans
333-
}
334-
else null
335-
}
336-
}
337-
338289
final class RichMapCanStep[K, V](private val underlying: collection.Map[K, V]) extends AnyVal with MakesAnyKeySeqStepper[K] with MakesAnyValueSeqStepper[V] {
339290
def keyStepper: AnyStepper[K] = new StepsAnyIterator[K](underlying.keysIterator)
340291
def valueStepper: AnyStepper[V] = new StepsAnyIterator[V](underlying.valuesIterator)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package scala.compat.java8.converterImpls
2+
3+
import language.implicitConversions
4+
5+
import scala.compat.java8.collectionImpl._
6+
import scala.compat.java8.runtime._
7+
8+
import Stepper._
9+
10+
private[java8] class StepsAnyIterator[A](_underlying: Iterator[A])
11+
extends StepsLikeIterator[A, StepsAnyIterator[A]](_underlying) {
12+
def semiclone() = new StepsAnyIterator(null)
13+
def next() = if (proxied ne null) proxied.nextStep else underlying.next
14+
}
15+
16+
private[java8] class StepsDoubleIterator(_underlying: Iterator[Double])
17+
extends StepsDoubleLikeIterator[StepsDoubleIterator](_underlying) {
18+
def semiclone() = new StepsDoubleIterator(null)
19+
def nextDouble() = if (proxied ne null) proxied.nextStep else underlying.next
20+
}
21+
22+
private[java8] class StepsIntIterator(_underlying: Iterator[Int])
23+
extends StepsIntLikeIterator[StepsIntIterator](_underlying) {
24+
def semiclone() = new StepsIntIterator(null)
25+
def nextInt() = if (proxied ne null) proxied.nextStep else underlying.next
26+
}
27+
28+
private[java8] class StepsLongIterator(_underlying: Iterator[Long])
29+
extends StepsLongLikeIterator[StepsLongIterator](_underlying) {
30+
def semiclone() = new StepsLongIterator(null)
31+
def nextLong() = if (proxied ne null) proxied.nextStep else underlying.next
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package scala.compat.java8.converterImpls
2+
3+
import language.implicitConversions
4+
5+
import scala.compat.java8.collectionImpl._
6+
import scala.compat.java8.runtime._
7+
8+
import Stepper._
9+
10+
private[java8] class StepperStringCodePoint(underlying: String, var i0: Int, var iN: Int) extends IntStepper with EfficientSubstep {
11+
def characteristics() = NonNull
12+
def estimateSize = iN - i0
13+
def hasNext = i0 < iN
14+
def nextInt() = {
15+
if (hasNext()) {
16+
val cp = underlying.codePointAt(i0)
17+
i0 += java.lang.Character.charCount(cp)
18+
cp
19+
}
20+
else throwNSEE
21+
}
22+
def substep() = {
23+
if (iN-3 > i0) {
24+
var half = (i0+iN) >>> 1
25+
if (java.lang.Character.isLowSurrogate(underlying.charAt(half))) half -= 1
26+
val ans = new StepperStringCodePoint(underlying, i0, half)
27+
i0 = half
28+
ans
29+
}
30+
else null
31+
}
32+
}
33+

0 commit comments

Comments
 (0)