Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutable.TreeMap.range does not work #10113

Closed
scabug opened this issue Dec 19, 2016 · 5 comments
Closed

mutable.TreeMap.range does not work #10113

scabug opened this issue Dec 19, 2016 · 5 comments

Comments

@scabug
Copy link

scabug commented Dec 19, 2016

Obtaining 'values' from range view of TreeMap returns all values from original map.

val tm: mutable.TreeMap[String, String] = mutable.TreeMap[String, String]()
tm.put("a", "a")
tm.put("b", "b")
tm.put("c", "c")
tm.put("d", "d")

println(s"scala: ${tm.range("b", "c").values.mkString(",")}")

val jtm = new util.TreeMap[String, String]()
jtm.put("a", "a")
jtm.put("b", "b")
jtm.put("c", "c")
jtm.put("d", "d")

println(s"java: ${
jtm.subMap("b", "c")
        .values()
        .stream()
        .collect(Collectors.joining(","))
    }")

Output:
scala: a,b,c,d
java: b

Also keySet for mutable.TreeSet works properly on range but for mutable.TreeMap - does not

val tm: mutable.TreeMap[String, String] = mutable.TreeMap[String, String]()
tm.put("a", "a")
tm.put("b", "b")
tm.put("c", "c")
tm.put("d", "d")

println(s"treeMap: ${tm.range("b", "c").keySet.mkString(",")}")

val ts: mutable.TreeSet[String] = mutable.TreeSet[String]()
ts.add("a")
ts.add("b")
ts.add("c")
ts.add("d")

println(s"treeSet: ${ts.range("b", "c").keySet.mkString(",")}")

Output:
treeMap: a,b,c,d
treeSet: b

@scabug
Copy link
Author

scabug commented Dec 19, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10113?orig=1
Reporter: @ichaki5748
Affected Versions: 2.12.1

@scabug
Copy link
Author

scabug commented Jan 10, 2017

@ichaki5748 said:
Hi Seth,

Please kindly take a look: scala/scala#5637

Thanks

@scabug
Copy link
Author

scabug commented Jan 17, 2017

@ichaki5748 said:
@seth, could you please kindly advise if I need to do something else so this JIRA is reviewed or I should just wait?

@scabug
Copy link
Author

scabug commented Jan 18, 2017

@SethTisue said:
well, we're often a bit slow, but we don't mind being prodded a bit, either :-)

I commented on the PR

@scabug scabug closed this as completed Jan 18, 2017
@scabug
Copy link
Author

scabug commented Mar 2, 2017

Dave Nutkins (DaveNutkins) said:
This also fixes this problem:

import scala_collection._
val map = mutable.TreeMap(3 -> 4, 4 -> 5, 5 -> 6)
map.to(4)

returning an empty TreeMap instead of TreeMap(3 -> 4, 4 -> 5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants