Skip to content

Commit 41243aa

Browse files
authored
Merge pull request #13 from lrytz/sortedRange
range methods on SortedSet / SortedMap
2 parents d4c8c3b + acf9f39 commit 41243aa

File tree

12 files changed

+79
-19
lines changed

12 files changed

+79
-19
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ unmanagedSourceDirectories in Compile += (
1111
else (sourceDirectory in Compile).value / "scala-2.11_2.12"
1212
)
1313

14-
crossScalaVersions := Seq("2.12.5", "2.13.0-M4-pre-20d3c21", "2.11.12")
14+
crossScalaVersions := Seq("2.12.5", "2.13.0-pre-b11db01", "2.11.12")
1515

1616
scalaVersion := crossScalaVersions.value.head
1717

src/main/scala-2.11_2.12/collection/compat_impl/package.scala renamed to src/main/scala-2.11_2.12/scala/collection/compat/CompatImpl.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package scala.collection
1+
package scala.collection.compat
22

3-
import scala.collection.generic._
3+
import scala.collection.generic.CanBuildFrom
44
import scala.collection.mutable.Builder
5-
import scala.reflect.ClassTag
5+
import scala.collection.{immutable, mutable}
66

7-
package object compat_impl {
7+
private[compat] object CompatImpl {
88
def simpleCBF[A, C](f: => Builder[A, C]): CanBuildFrom[Any, A, C] = new CanBuildFrom[Any, A, C] {
99
def apply(from: Any): Builder[A, C] = apply()
1010
def apply(): Builder[A, C] = f

src/main/scala-2.11_2.12/collection/compat/package.scala renamed to src/main/scala-2.11_2.12/scala/collection/compat/package.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import scala.reflect.ClassTag
66

77
/** The collection compatibility API */
88
package object compat {
9-
import scala.collection.compat_impl._
9+
import CompatImpl._
1010

1111
implicit def genericCompanionToCBF[A, CC[X] <: GenTraversable[X]](fact: GenericCompanion[CC]): CanBuildFrom[Any, A, CC[A]] =
1212
simpleCBF(fact.newBuilder[A])
@@ -48,6 +48,12 @@ package object compat {
4848
def lazyAppendAll(as: => TraversableOnce[A]): Stream[A] = stream.append(as)
4949
}
5050

51+
implicit class SortedExtensionMethods[K, T <: Sorted[K, T]](private val fact: Sorted[K, T]) {
52+
def rangeFrom(from: K): T = fact.from(from)
53+
def rangeTo(to: K): T = fact.to(to)
54+
def rangeUntil(until: K): T = fact.until(until)
55+
}
56+
5157
// This really belongs into scala.collection but there's already a package object in scala-library so we can't add to it
5258
type IterableOnce[+X] = TraversableOnce[X]
5359
}

src/test/scala/collection/BuildFromTest.scala renamed to src/test/scala/test/scala/collection/BuildFromTest.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package scala.collection
1+
package test.scala.collection
22

33
import org.junit.Test
44

5-
import scala.collection.mutable.{ArrayBuffer, Builder, ListBuffer}
6-
import scala.collection.immutable.{HashMap, List, TreeMap, TreeSet}
75
import scala.collection.compat._
6+
import scala.collection.immutable.{HashMap, TreeMap, TreeSet}
7+
import scala.collection.mutable.{ArrayBuffer, Builder, ListBuffer}
8+
import scala.collection.{BitSet, BuildFrom, SortedMap, SortedSet, immutable, mutable}
89

910
// Tests copied from the 2.13 scala-library
1011
class BuildFromTest {

src/test/scala/collection/CollectionTest.scala renamed to src/test/scala/test/scala/collection/CollectionTest.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
package collection
1+
package test.scala.collection
22

3-
import java.util
4-
5-
import org.junit.Test
63
import org.junit.Assert._
4+
import org.junit.Test
75

8-
import scala.collection.immutable.BitSet
96
import scala.collection.compat._
7+
import scala.collection.immutable.BitSet
108

119
class CollectionTest {
1210
@Test

src/test/scala/collection/FactoryTest.scala renamed to src/test/scala/test/scala/collection/FactoryTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
package collection
1+
package test.scala.collection
22

33
import org.junit.{Assert, Test}
44

5-
import scala.collection.{BitSet, Factory, Iterable, immutable, mutable}
65
import scala.collection.compat._
6+
import scala.collection.{BitSet, Factory, immutable, mutable}
77

88
class FactoryTest {
99

1010
implicitly[Factory[Char, String]]
1111
implicitly[Factory[Char, Array[Char]]]
12-
implicitly[Factory[Int, BitSet]]
12+
implicitly[Factory[Int, collection.BitSet]]
1313
implicitly[Factory[Int, mutable.BitSet]]
1414
implicitly[Factory[Int, immutable.BitSet]]
1515

src/test/scala/collection/ImmutableArrayTest.scala renamed to src/test/scala/test/scala/collection/ImmutableArrayTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package collection
1+
package test.scala.collection
22

33
import org.junit.{Assert, Test}
44

0 commit comments

Comments
 (0)