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
ListSet.filter scrambles order of insertion #8985
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8985?orig=1 |
@som-snytt said: Most operations reverse when building a new collection, but bulk add re-reverses the receiver. scala> ListSet('a' to 'z': _*)
res7: scala.collection.immutable.ListSet[Char] = ListSet(z, y, x, w, v, u, t, s, r, q, p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, a)
scala> ListSet('a' to 'z': _*).filter(_ != 'm')
res9: scala.collection.immutable.ListSet[Char] = ListSet(a, b, c, d, e, f, g, h, i, j, k, l, n, o, p, q, r, s, t, u, v, w, x, y, z)
scala> res9 ++ ('1' to '9')
res10: scala.collection.immutable.ListSet[Char] = ListSet(9, 8, 7, 6, 5, 4, 3, 2, 1, a, b, c, d, e, f, g, h, i, j, k, l, n, o, p, q, r, s, t, u, v, w, x, y, z) |
Peng Cheng (peng) said: /** Selects all elements of this $coll which satisfy a predicate. |
@som-snytt said: "A traversable class might or might not have two properties: strictness and orderedness. Neither is represented as a type." That is, you can't tell by looking whether it is ordered. A Seq is ordered because the docs say so. Since a ListSet isn't actually ListLike, maybe ListSet should be ListiveSet. |
Peng Cheng (peng) said: |
@SethTisue said (edited on Jan 19, 2016 10:08:31 PM UTC): Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_66).
scala> import scala.collection.immutable.ListSet
import scala.collection.immutable.ListSet
scala> ListSet('a' to 'z': _*)
res1: scala.collection.immutable.ListSet[Char] = ListSet(z, y, x, w, v, u, t, s, r, q, p, o, n, m, l, k, j, i, h, g, f, e, d, c, b, a)
scala> res1.filter(_ => true)
res2: scala.collection.immutable.ListSet[Char] = ListSet(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) |
@SethTisue said: At minimum, the documentation ought to be a lot better. I think this is a little-used collection, so I've provisionally changed the milestone to Backlog. |
@lrytz said: |
run following code will reverse the order of "_" and "model" in the ListSet:
val set = ListSet("", "model", "temp").filter( != "temp")
this will yield an ordered set in which "" precedes "model", different from ListSet("","model")
The text was updated successfully, but these errors were encountered: