Fixed bug in Sorted "to" not using the ordering. Closes SI-4930, no review.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25574 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2011-08-27 18:01:40 +00:00
parent e77200a9a8
commit 1ca8734604
3 changed files with 14 additions and 2 deletions

View File

@ -71,11 +71,10 @@ trait Sorted[K, +This <: Sorted[K, This]] {
* @param to The upper-bound (inclusive) of the ranged projection.
*/
def to(to: K): This = {
// tough!
val i = keySet.from(to).iterator
if (i.isEmpty) return repr
val next = i.next
if (next == to)
if (compare(next, to) == 0)
if (i.isEmpty) repr
else until(i.next)
else

View File

@ -0,0 +1,2 @@
List(1)
List(1)

View File

@ -0,0 +1,11 @@
import collection.immutable.SortedMap
object Test {
implicit val ord: Ordering[Array[Byte]] = Ordering.by((_: Array[Byte]).toIterable)
def main(args: Array[String]): Unit = {
val m = SortedMap(Array[Byte](1) -> 0)
println(m.to(Array[Byte](1)) flatMap (_._1.mkString))
println(m.from(Array[Byte](1)) flatMap (_._1.mkString))
}
}