@@ -39,76 +39,79 @@ object PrimitiveIteratorConverters {
39
39
/** Packages a Scala `Iterator` to a manually specialized Java variant `That` */
40
40
def fromScala (it : Iterator [A ]): That
41
41
}
42
-
42
+
43
43
/** Implementation of wrapping of `java.util.Iterator[Double]` or `scala.collection.Iterator[Double]` as a `java.util.PrimitiveIterator.OfDouble` */
44
- implicit val specializer_PrimitiveIteratorDouble = new SpecializerOfIterators [Double , PrimitiveIterator .OfDouble ] {
45
- /** Packages a `java.util.Iterator[Double]` as a `java.util.PrimitiveIterator.OfDouble` */
46
- def fromJava (it : JIterator [Double ]): PrimitiveIterator .OfDouble =
47
- new wrappers.IteratorPrimitiveDoubleWrapper (it.asInstanceOf [JIterator [java.lang.Double ]])
48
-
49
- /** Packages a `scala.collection.Iterator[Double]` as a `java.util.PrimitiveIterator.OfDouble` */
50
- def fromScala (it : Iterator [Double ]): PrimitiveIterator .OfDouble = new PrimitiveIterator .OfDouble {
51
- def hasNext = it.hasNext
52
- override def next () = it.next().asInstanceOf [java.lang.Double ]
53
- def nextDouble () = it.next()
54
- override def remove (): Unit = { throw new UnsupportedOperationException (" remove on scala.collection.Iterator" ) }
55
- override def forEachRemaining (c : java.util.function.Consumer [_ >: java.lang.Double ]): Unit = {
56
- while (it.hasNext) c.accept(it.next())
57
- }
58
- override def forEachRemaining (c : java.util.function.DoubleConsumer ): Unit = {
59
- while (it.hasNext) c.accept(it.next())
44
+ implicit val specializer_PrimitiveIteratorDouble : SpecializerOfIterators [Double , PrimitiveIterator .OfDouble ] =
45
+ new SpecializerOfIterators {
46
+ /** Packages a `java.util.Iterator[Double]` as a `java.util.PrimitiveIterator.OfDouble` */
47
+ def fromJava (it : JIterator [Double ]): PrimitiveIterator .OfDouble =
48
+ new wrappers.IteratorPrimitiveDoubleWrapper (it.asInstanceOf [JIterator [java.lang.Double ]])
49
+
50
+ /** Packages a `scala.collection.Iterator[Double]` as a `java.util.PrimitiveIterator.OfDouble` */
51
+ def fromScala (it : Iterator [Double ]): PrimitiveIterator .OfDouble = new PrimitiveIterator .OfDouble {
52
+ def hasNext = it.hasNext
53
+ override def next () = it.next().asInstanceOf [java.lang.Double ]
54
+ def nextDouble () = it.next()
55
+ override def remove (): Unit = { throw new UnsupportedOperationException (" remove on scala.collection.Iterator" ) }
56
+ override def forEachRemaining (c : java.util.function.Consumer [_ >: java.lang.Double ]): Unit = {
57
+ while (it.hasNext) c.accept(it.next())
58
+ }
59
+ override def forEachRemaining (c : java.util.function.DoubleConsumer ): Unit = {
60
+ while (it.hasNext) c.accept(it.next())
61
+ }
60
62
}
61
63
}
62
- }
63
-
64
+
64
65
/** Implementation of wrapping of `java.util.Iterator[Int]` or `scala.collection.Iterator[Int]` as a `java.util.PrimitiveIterator.OfInt` */
65
- implicit val specializer_PrimitiveIteratorInt = new SpecializerOfIterators [Int , PrimitiveIterator .OfInt ] {
66
- /** Packages a `java.util.Iterator[Int]` as a `java.util.PrimitiveIterator.OfInt` */
67
- def fromJava (it : JIterator [Int ]): PrimitiveIterator .OfInt =
68
- new wrappers.IteratorPrimitiveIntWrapper (it.asInstanceOf [JIterator [java.lang.Integer ]])
69
-
70
- /** Packages a `scala.collection.Iterator[Int]` as a `java.util.PrimitiveIterator.OfInt` */
71
- def fromScala (it : Iterator [Int ]): PrimitiveIterator .OfInt = new PrimitiveIterator .OfInt {
72
- def hasNext = it.hasNext
73
- override def next () = it.next().asInstanceOf [java.lang.Integer ]
74
- def nextInt () = it.next()
75
- override def remove (): Unit = { throw new UnsupportedOperationException (" remove on scala.collection.Iterator" ) }
76
- override def forEachRemaining (c : java.util.function.Consumer [_ >: java.lang.Integer ]): Unit = {
77
- while (it.hasNext) c.accept(it.next())
78
- }
79
- override def forEachRemaining (c : java.util.function.IntConsumer ): Unit = {
80
- while (it.hasNext) c.accept(it.next())
66
+ implicit val specializer_PrimitiveIteratorInt : SpecializerOfIterators [Int , PrimitiveIterator .OfInt ] =
67
+ new SpecializerOfIterators {
68
+ /** Packages a `java.util.Iterator[Int]` as a `java.util.PrimitiveIterator.OfInt` */
69
+ def fromJava (it : JIterator [Int ]): PrimitiveIterator .OfInt =
70
+ new wrappers.IteratorPrimitiveIntWrapper (it.asInstanceOf [JIterator [java.lang.Integer ]])
71
+
72
+ /** Packages a `scala.collection.Iterator[Int]` as a `java.util.PrimitiveIterator.OfInt` */
73
+ def fromScala (it : Iterator [Int ]): PrimitiveIterator .OfInt = new PrimitiveIterator .OfInt {
74
+ def hasNext = it.hasNext
75
+ override def next () = it.next().asInstanceOf [java.lang.Integer ]
76
+ def nextInt () = it.next()
77
+ override def remove (): Unit = { throw new UnsupportedOperationException (" remove on scala.collection.Iterator" ) }
78
+ override def forEachRemaining (c : java.util.function.Consumer [_ >: java.lang.Integer ]): Unit = {
79
+ while (it.hasNext) c.accept(it.next())
80
+ }
81
+ override def forEachRemaining (c : java.util.function.IntConsumer ): Unit = {
82
+ while (it.hasNext) c.accept(it.next())
83
+ }
81
84
}
82
85
}
83
- }
84
-
86
+
85
87
/** Implementation of wrapping of `java.util.Iterator[Long]` or `scala.collection.Iterator[Long]` as a `java.util.PrimitiveIterator.OfLong` */
86
- implicit val specializer_PrimitiveIteratorLong = new SpecializerOfIterators [Long , PrimitiveIterator .OfLong ] {
87
- /** Packages a `java.util.Iterator[Long]` as a `java.util.PrimitiveIterator.OfLong` */
88
- def fromJava (it : JIterator [Long ]): PrimitiveIterator .OfLong =
89
- new wrappers.IteratorPrimitiveLongWrapper (it.asInstanceOf [JIterator [java.lang.Long ]])
90
-
91
- /** Packages a `scala.collection.Iterator[Long]` as a `java.util.PrimitiveIterator.OfLong` */
92
- def fromScala (it : Iterator [Long ]): PrimitiveIterator .OfLong = new PrimitiveIterator .OfLong {
93
- def hasNext = it.hasNext
94
- override def next () = it.next().asInstanceOf [java.lang.Long ]
95
- def nextLong () = it.next()
96
- override def remove (): Unit = { throw new UnsupportedOperationException (" remove on scala.collection.Iterator" ) }
97
- override def forEachRemaining (c : java.util.function.Consumer [_ >: java.lang.Long ]): Unit = {
98
- while (it.hasNext) c.accept(it.next())
99
- }
100
- override def forEachRemaining (c : java.util.function.LongConsumer ): Unit = {
101
- while (it.hasNext) c.accept(it.next())
88
+ implicit val specializer_PrimitiveIteratorLong : SpecializerOfIterators [Long , PrimitiveIterator .OfLong ] =
89
+ new SpecializerOfIterators {
90
+ /** Packages a `java.util.Iterator[Long]` as a `java.util.PrimitiveIterator.OfLong` */
91
+ def fromJava (it : JIterator [Long ]): PrimitiveIterator .OfLong =
92
+ new wrappers.IteratorPrimitiveLongWrapper (it.asInstanceOf [JIterator [java.lang.Long ]])
93
+
94
+ /** Packages a `scala.collection.Iterator[Long]` as a `java.util.PrimitiveIterator.OfLong` */
95
+ def fromScala (it : Iterator [Long ]): PrimitiveIterator .OfLong = new PrimitiveIterator .OfLong {
96
+ def hasNext = it.hasNext
97
+ override def next () = it.next().asInstanceOf [java.lang.Long ]
98
+ def nextLong () = it.next()
99
+ override def remove (): Unit = { throw new UnsupportedOperationException (" remove on scala.collection.Iterator" ) }
100
+ override def forEachRemaining (c : java.util.function.Consumer [_ >: java.lang.Long ]): Unit = {
101
+ while (it.hasNext) c.accept(it.next())
102
+ }
103
+ override def forEachRemaining (c : java.util.function.LongConsumer ): Unit = {
104
+ while (it.hasNext) c.accept(it.next())
105
+ }
102
106
}
103
107
}
104
- }
105
-
108
+
106
109
/** Provides conversions from Java `Iterator` to manually specialized `PrimitiveIterator` variants, when available */
107
110
implicit final class RichJavaIteratorToPrimitives [A ](private val underlying : JIterator [A ]) extends AnyVal {
108
111
/** Wraps this `java.util.Iterator` as a manually specialized variant, if possible */
109
112
def asPrimitive [That ](implicit specOp : SpecializerOfIterators [A , That ]): That = specOp.fromJava(underlying)
110
113
}
111
-
114
+
112
115
/** Provides conversions from Scala `Iterator` to manually specialized `PrimitiveIterator` variants, when available */
113
116
implicit final class RichIteratorToPrimitives [A ](private val underlying : Iterator [A ]) extends AnyVal {
114
117
/** Wraps this `scala.collection.Iterator` as a manually specialized `java.util.PrimitiveIterator` variant, if possible */
0 commit comments