Re: Sorted structures lose their ordering when mapped
Tobin Yehle <[email protected]> Tue, 29 Nov 2016 06:23:46 +0000
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CABx_kgTMBBOzoUL-MN_rmECJH_LRXi59N16N0RUu+ehbwgL-ng@mail.gmail.com> |
--001a1137b834219fd805426aa279
Content-Type: text/plain; charset=UTF-8
On the immutable side, I think the only concrete collections that inherit
from SortedSet are TreeSet and BitSet. I think the problem also exists in
TreeMap, and all the mutable versions of these three structures. Mutable
BitSets are probably the largest use case.
Use cases for TreeSet and TreeMap are for situations where a HashSet/Map
would be good, but in-order traversals are also needed. They provide Log
insertions/deletions/lookups.
My thought is that sorted collections should retain their ordering whenever
possible.
scala> val set = SortedSet(1,2,3)(ord=Ordering.Int.reverse)
set: scala.collection.SortedSet[Int] = TreeSet(3, 2, 1)
scala> set.map(identity)
res0: scala.collection.SortedSet[Int] = TreeSet(1, 2, 3) should be
TreeSet(3, 2, 1)?
scala> set.map(_*2)
res1: scala.collection.SortedSet[Int] = TreeSet(2, 4, 6) should be
TreeSet(6, 4, 2)?
and if possible
scala> set.map(_*2)(collection.breakOut) : BitSet
res2: scala.collection.BitSet = BitSet(2, 4, 6)
should be BitSet(6, 4, 2)?
an impossible case is when the type of the objects in the container changes
scala> set.map("a" * _)
res3: scala.collection.SortedSet[String] = TreeSet(a, aa, aaa) this
seems like correct behavior
On Mon, Nov 28, 2016 at 10:34 PM Vlad Patryshev <[email protected]>
wrote:
> It was a pretty nice (counter-)example, but I wonder what is "SortedSet"?
> And of course the next question will be - how should map be defined on
> "SortedSet"?
>
> It's not a joke, it's a serious question.
>
> Thanks,
> -Vlad
>
> On Mon, Nov 28, 2016 at 8:14 PM, Tobin Yehle <[email protected]> wrote:
>
> Not sure if I'm really posting this in the right place, but:
>
> Calling map on a collection that requires an implicit ordering results in
> some surprising behavior. For example:
>
> scala> val set = SortedSet(1,2,3)(ord=Ordering.Int.reverse)
> set: scala.collection.SortedSet[Int] = TreeSet(3, 2, 1)
>
>
> scala> set.firstKey == set.map(identity).firstKey
> res0: Boolean = false
>
> My feeling is that mapping the identity function over any collection
> should not change anything.
>
> In this case it is clear what is happening. The CanBuildFrom provided by
> SortedSet is pulling an Ordering instance out of predef (Ordering.Int)
> instead of using the ordering from the origin collection.
> scala> set.toList
> res1: List[Int] = List(3, 2, 1)
>
>
> scala> set.map(identity).toList
> res2: List[Int] = List(1, 2, 3)
>
> scala> set.ordering
> res3: Ordering[Int] = scala.math.Ordering$$anon$4@3ff3275b
>
> scala> set.map(identity).ordering
> res4: Ordering[Int] = scala.math.Ordering$Int$@7fa85a55
>
> I think this can be fixed by providing a more specific CanBuildFrom
> instance to be used when mapping between two sorted collections that
> contain the same type.
>
> i.e. Provide a CanBuildFrom[Sorted[K, _], K, Sorted[K, _]] somewhere that
> has precedence over the more generic usual CanBuildFrom[CC[_], A, CC[A]]
>
> I'm not sure how it could be done, but the static overloading resolution
> rules make this possible, I think.
>
> --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>
>
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "scala-language" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/scala-language/Q5A1TTEZN4Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
--001a1137b834219fd805426aa279
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On the immutable side, I think the only concrete collectio=
ns that inherit from SortedSet are TreeSet and BitSet. I think the problem =
also exists in TreeMap, and all the mutable versions of these three structu=
res. Mutable BitSets are probably the largest use case.<div><br></div><div>=
Use cases for TreeSet and TreeMap are for situations where a HashSet/Map wo=
uld be good, but in-order traversals are also needed. They provide Log inse=
rtions/deletions/lookups.</div><div><br></div><div>My thought is that sorte=
d collections should retain their ordering whenever possible.</div><div><br=
></div><div><div>scala> val set =3D SortedSet(1,2,3)(ord=3DOrdering.Int.=
reverse)</div><div>set: scala.collection.SortedSet[Int] =3D TreeSet(3, 2, 1=
)</div><div><br></div><div>scala> set.map(identity)</div><div>res0: scal=
a.collection.SortedSet[Int] =3D TreeSet(1, 2, 3) =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0should be TreeSet(3, 2, 1)?</div><div><br></div><div>scala> se=
t.map(_*2)</div><div>res1: scala.collection.SortedSet[Int] =3D TreeSet(2, 4=
, 6) =C2=A0 =C2=A0 =C2=A0 =C2=A0 should be TreeSet(6, 4, 2)?</div></div><di=
v><br></div><div>and if possible</div><div><br></div><div><div>scala> se=
t.map(_*2)(collection.breakOut) : BitSet</div><div>res2: scala.collection.B=
itSet =3D BitSet(2, 4, 6) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0should be BitSet(6, 4, 2)?</div></div><di=
v><br></div><div>an impossible case is when the type of the objects in the =
container changes</div><div><br></div><div><div>scala> set.map("a&q=
uot; * _)</div><div>res3: scala.collection.SortedSet[String] =3D TreeSet(a,=
aa, aaa) =C2=A0 =C2=A0 =C2=A0 =C2=A0this seems like correct behavior</div>=
</div><div><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">=
On Mon, Nov 28, 2016 at 10:34 PM Vlad Patryshev <<a href=3D"mailto:vpatr=
[email protected]">[email protected]</a>> wrote:<br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex"><div dir=3D"ltr" class=3D"gmail_msg">It was a pretty nice=
(counter-)example, but I wonder what is "SortedSet"? And of cour=
se the next question will be - how should map be defined on "SortedSet=
"?<div class=3D"gmail_msg"><br class=3D"gmail_msg"></div><div class=3D=
"gmail_msg">It's not a joke, it's a serious question.</div></div><d=
iv class=3D"gmail_extra gmail_msg"><br clear=3D"all" class=3D"gmail_msg"><d=
iv class=3D"gmail_msg"><div class=3D"m_-5042556665519706739gmail_signature =
gmail_msg" data-smartmail=3D"gmail_signature">Thanks,<br class=3D"gmail_msg=
">-Vlad</div></div>
<br class=3D"gmail_msg"><div class=3D"gmail_quote gmail_msg"></div></div><d=
iv class=3D"gmail_extra gmail_msg"><div class=3D"gmail_quote gmail_msg">On =
Mon, Nov 28, 2016 at 8:14 PM, Tobin Yehle <span dir=3D"ltr" class=3D"gmail_=
msg"><<a href=3D"mailto:[email protected]" class=3D"gmail_msg" target=
=3D"_blank">[email protected]</a>></span> wrote:<br class=3D"gmail_ms=
g"></div></div><div class=3D"gmail_extra gmail_msg"><div class=3D"gmail_quo=
te gmail_msg"><blockquote class=3D"gmail_quote gmail_msg" style=3D"margin:0=
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr" cla=
ss=3D"gmail_msg"><div class=3D"gmail_msg">Not sure if I'm really postin=
g this in the right place, but:</div><div class=3D"gmail_msg"><br class=3D"=
gmail_msg"></div>Calling map on a collection that requires an implicit orde=
ring results in some surprising behavior. For example:<div class=3D"gmail_m=
sg"><div class=3D"gmail_msg"><br class=3D"gmail_msg"></div><div class=3D"m_=
-5042556665519706739m_3440269965916649927prettyprint gmail_msg" style=3D"ba=
ckground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:=
solid;border-width:1px;word-wrap:break-word"><code class=3D"m_-504255666551=
9706739m_3440269965916649927prettyprint gmail_msg"><div class=3D"m_-5042556=
665519706739m_3440269965916649927subprettyprint gmail_msg"><span style=3D"c=
olor:#000" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pr=
ettify gmail_msg">scala</span><span style=3D"color:#660" class=3D"m_-504255=
6665519706739m_3440269965916649927styled-by-prettify gmail_msg">></span>=
<span style=3D"color:#000" class=3D"m_-5042556665519706739m_344026996591664=
9927styled-by-prettify gmail_msg"> val </span><span style=3D"color:#008" cl=
ass=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_=
msg">set</span><span style=3D"color:#000" class=3D"m_-5042556665519706739m_=
3440269965916649927styled-by-prettify gmail_msg"> </span><span style=3D"col=
or:#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg">=3D</span><span style=3D"color:#000" class=3D"m_-5042556665=
519706739m_3440269965916649927styled-by-prettify gmail_msg"> </span><span s=
tyle=3D"color:#606" class=3D"m_-5042556665519706739m_3440269965916649927sty=
led-by-prettify gmail_msg">SortedSet</span><span style=3D"color:#660" class=
=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg=
">(</span><span style=3D"color:#066" class=3D"m_-5042556665519706739m_34402=
69965916649927styled-by-prettify gmail_msg">1</span><span style=3D"color:#6=
60" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify =
gmail_msg">,</span><span style=3D"color:#066" class=3D"m_-50425566655197067=
39m_3440269965916649927styled-by-prettify gmail_msg">2</span><span style=3D=
"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-=
prettify gmail_msg">,</span><span style=3D"color:#066" class=3D"m_-50425566=
65519706739m_3440269965916649927styled-by-prettify gmail_msg">3</span><span=
style=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927s=
tyled-by-prettify gmail_msg">)(</span><span style=3D"color:#000" class=3D"m=
_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">ord=
</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_34402699=
65916649927styled-by-prettify gmail_msg">=3D</span><span style=3D"color:#60=
6" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify g=
mail_msg">Ordering</span><span style=3D"color:#660" class=3D"m_-50425566655=
19706739m_3440269965916649927styled-by-prettify gmail_msg">.</span><span st=
yle=3D"color:#606" class=3D"m_-5042556665519706739m_3440269965916649927styl=
ed-by-prettify gmail_msg">Int</span><span style=3D"color:#660" class=3D"m_-=
5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">.</sp=
an><span style=3D"color:#000" class=3D"m_-5042556665519706739m_344026996591=
6649927styled-by-prettify gmail_msg">reverse</span><span style=3D"color:#66=
0" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify g=
mail_msg">)</span><span style=3D"color:#000" class=3D"m_-504255666551970673=
9m_3440269965916649927styled-by-prettify gmail_msg"><br class=3D"gmail_msg"=
></span><span style=3D"color:#008" class=3D"m_-5042556665519706739m_3440269=
965916649927styled-by-prettify gmail_msg">set</span><span style=3D"color:#6=
60" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify =
gmail_msg">:</span><span style=3D"color:#000" class=3D"m_-50425566655197067=
39m_3440269965916649927styled-by-prettify gmail_msg"> scala</span><span sty=
le=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927style=
d-by-prettify gmail_msg">.</span><span style=3D"color:#000" class=3D"m_-504=
2556665519706739m_3440269965916649927styled-by-prettify gmail_msg">collecti=
on</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_344026=
9965916649927styled-by-prettify gmail_msg">.</span><span style=3D"color:#60=
6" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify g=
mail_msg">SortedSet</span><span style=3D"color:#660" class=3D"m_-5042556665=
519706739m_3440269965916649927styled-by-prettify gmail_msg">[</span><span s=
tyle=3D"color:#606" class=3D"m_-5042556665519706739m_3440269965916649927sty=
led-by-prettify gmail_msg">Int</span><span style=3D"color:#660" class=3D"m_=
-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">]</s=
pan><span style=3D"color:#000" class=3D"m_-5042556665519706739m_34402699659=
16649927styled-by-prettify gmail_msg"> </span><span style=3D"color:#660" cl=
ass=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_=
msg">=3D</span><span style=3D"color:#000" class=3D"m_-5042556665519706739m_=
3440269965916649927styled-by-prettify gmail_msg"> </span><span style=3D"col=
or:#606" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg">TreeSet</span><span style=3D"color:#660" class=3D"m_-504255=
6665519706739m_3440269965916649927styled-by-prettify gmail_msg">(</span><sp=
an style=3D"color:#066" class=3D"m_-5042556665519706739m_344026996591664992=
7styled-by-prettify gmail_msg">3</span><span style=3D"color:#660" class=3D"=
m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">,<=
/span><span style=3D"color:#000" class=3D"m_-5042556665519706739m_344026996=
5916649927styled-by-prettify gmail_msg"> </span><span style=3D"color:#066" =
class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmai=
l_msg">2</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_=
3440269965916649927styled-by-prettify gmail_msg">,</span><span style=3D"col=
or:#000" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg"> </span><span style=3D"color:#066" class=3D"m_-504255666551=
9706739m_3440269965916649927styled-by-prettify gmail_msg">1</span><span sty=
le=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927style=
d-by-prettify gmail_msg">)</span><span style=3D"color:#000" class=3D"m_-504=
2556665519706739m_3440269965916649927styled-by-prettify gmail_msg"><br clas=
s=3D"gmail_msg"><br class=3D"gmail_msg"><br class=3D"gmail_msg">scala</span=
><span style=3D"color:#660" class=3D"m_-5042556665519706739m_34402699659166=
49927styled-by-prettify gmail_msg">></span><span style=3D"color:#000" cl=
ass=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_=
msg"> </span><span style=3D"color:#008" class=3D"m_-5042556665519706739m_34=
40269965916649927styled-by-prettify gmail_msg">set</span><span style=3D"col=
or:#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg">.</span><span style=3D"color:#000" class=3D"m_-504255666551=
9706739m_3440269965916649927styled-by-prettify gmail_msg">firstKey </span><=
span style=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649=
927styled-by-prettify gmail_msg">=3D=3D</span><span style=3D"color:#000" cl=
ass=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_=
msg"> </span><span style=3D"color:#008" class=3D"m_-5042556665519706739m_34=
40269965916649927styled-by-prettify gmail_msg">set</span><span style=3D"col=
or:#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg">.</span><span style=3D"color:#000" class=3D"m_-504255666551=
9706739m_3440269965916649927styled-by-prettify gmail_msg">map</span><span s=
tyle=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927sty=
led-by-prettify gmail_msg">(</span><span style=3D"color:#000" class=3D"m_-5=
042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">identi=
ty</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_344026=
9965916649927styled-by-prettify gmail_msg">).</span><span style=3D"color:#0=
00" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify =
gmail_msg">firstKey<br class=3D"gmail_msg">res0</span><span style=3D"color:=
#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettif=
y gmail_msg">:</span><span style=3D"color:#000" class=3D"m_-504255666551970=
6739m_3440269965916649927styled-by-prettify gmail_msg"> </span><span style=
=3D"color:#606" class=3D"m_-5042556665519706739m_3440269965916649927styled-=
by-prettify gmail_msg">Boolean</span><span style=3D"color:#000" class=3D"m_=
-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg"> </s=
pan><span style=3D"color:#660" class=3D"m_-5042556665519706739m_34402699659=
16649927styled-by-prettify gmail_msg">=3D</span><span style=3D"color:#000" =
class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmai=
l_msg"> </span><span style=3D"color:#008" class=3D"m_-5042556665519706739m_=
3440269965916649927styled-by-prettify gmail_msg">false</span></div></code><=
/div><div class=3D"gmail_msg"><br class=3D"gmail_msg"></div></div><div clas=
s=3D"gmail_msg">My feeling is that mapping the identity function over any c=
ollection should not change anything.</div><div class=3D"gmail_msg"><br cla=
ss=3D"gmail_msg"></div><div class=3D"gmail_msg">In this case it is clear wh=
at is happening. The CanBuildFrom provided by SortedSet is pulling an Order=
ing instance out of predef (Ordering.Int) instead of using the ordering fro=
m the origin collection.</div><div class=3D"m_-5042556665519706739m_3440269=
965916649927prettyprint gmail_msg" style=3D"background-color:rgb(250,250,25=
0);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-w=
rap:break-word"><code class=3D"m_-5042556665519706739m_3440269965916649927p=
rettyprint gmail_msg"><div class=3D"m_-5042556665519706739m_344026996591664=
9927subprettyprint gmail_msg"><span style=3D"color:#000" class=3D"m_-504255=
6665519706739m_3440269965916649927styled-by-prettify gmail_msg">scala</span=
><span style=3D"color:#660" class=3D"m_-5042556665519706739m_34402699659166=
49927styled-by-prettify gmail_msg">></span><span style=3D"color:#000" cl=
ass=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_=
msg"> </span><span style=3D"color:#008" class=3D"m_-5042556665519706739m_34=
40269965916649927styled-by-prettify gmail_msg">set</span><span style=3D"col=
or:#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg">.</span><span style=3D"color:#000" class=3D"m_-504255666551=
9706739m_3440269965916649927styled-by-prettify gmail_msg">toList<br class=
=3D"gmail_msg">res1</span><span style=3D"color:#660" class=3D"m_-5042556665=
519706739m_3440269965916649927styled-by-prettify gmail_msg">:</span><span s=
tyle=3D"color:#000" class=3D"m_-5042556665519706739m_3440269965916649927sty=
led-by-prettify gmail_msg"> </span><span style=3D"color:#606" class=3D"m_-5=
042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">List</=
span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965=
916649927styled-by-prettify gmail_msg">[</span><span style=3D"color:#606" c=
lass=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail=
_msg">Int</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m=
_3440269965916649927styled-by-prettify gmail_msg">]</span><span style=3D"co=
lor:#000" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pre=
ttify gmail_msg"> </span><span style=3D"color:#660" class=3D"m_-50425566655=
19706739m_3440269965916649927styled-by-prettify gmail_msg">=3D</span><span =
style=3D"color:#000" class=3D"m_-5042556665519706739m_3440269965916649927st=
yled-by-prettify gmail_msg"> </span><span style=3D"color:#606" class=3D"m_-=
5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">List<=
/span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_344026996=
5916649927styled-by-prettify gmail_msg">(</span><span style=3D"color:#066" =
class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmai=
l_msg">3</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_=
3440269965916649927styled-by-prettify gmail_msg">,</span><span style=3D"col=
or:#000" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-pret=
tify gmail_msg"> </span><span style=3D"color:#066" class=3D"m_-504255666551=
9706739m_3440269965916649927styled-by-prettify gmail_msg">2</span><span sty=
le=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927style=
d-by-prettify gmail_msg">,</span><span style=3D"color:#000" class=3D"m_-504=
2556665519706739m_3440269965916649927styled-by-prettify gmail_msg"> </span>=
<span style=3D"color:#066" class=3D"m_-5042556665519706739m_344026996591664=
9927styled-by-prettify gmail_msg">1</span><span style=3D"color:#660" class=
=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg=
">)</span><span style=3D"color:#000" class=3D"m_-5042556665519706739m_34402=
69965916649927styled-by-prettify gmail_msg"><br class=3D"gmail_msg"><br cla=
ss=3D"gmail_msg"><br class=3D"gmail_msg">scala</span><span style=3D"color:#=
660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify=
gmail_msg">></span><span style=3D"color:#000" class=3D"m_-5042556665519=
706739m_3440269965916649927styled-by-prettify gmail_msg"> </span><span styl=
e=3D"color:#008" class=3D"m_-5042556665519706739m_3440269965916649927styled=
-by-prettify gmail_msg">set</span><span style=3D"color:#660" class=3D"m_-50=
42556665519706739m_3440269965916649927styled-by-prettify gmail_msg">.</span=
><span style=3D"color:#000" class=3D"m_-5042556665519706739m_34402699659166=
49927styled-by-prettify gmail_msg">map</span><span style=3D"color:#660" cla=
ss=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_m=
sg">(</span><span style=3D"color:#000" class=3D"m_-5042556665519706739m_344=
0269965916649927styled-by-prettify gmail_msg">identity</span><span style=3D=
"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-=
prettify gmail_msg">).</span><span style=3D"color:#000" class=3D"m_-5042556=
665519706739m_3440269965916649927styled-by-prettify gmail_msg">toList<br cl=
ass=3D"gmail_msg">res2</span><span style=3D"color:#660" class=3D"m_-5042556=
665519706739m_3440269965916649927styled-by-prettify gmail_msg">:</span><spa=
n style=3D"color:#000" class=3D"m_-5042556665519706739m_3440269965916649927=
styled-by-prettify gmail_msg"> </span><span style=3D"color:#606" class=3D"m=
_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">Lis=
t</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_3440269=
965916649927styled-by-prettify gmail_msg">[</span><span style=3D"color:#606=
" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gm=
ail_msg">Int</span><span style=3D"color:#660" class=3D"m_-50425566655197067=
39m_3440269965916649927styled-by-prettify gmail_msg">]</span><span style=3D=
"color:#000" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-=
prettify gmail_msg"> </span><span style=3D"color:#660" class=3D"m_-50425566=
65519706739m_3440269965916649927styled-by-prettify gmail_msg">=3D</span><sp=
an style=3D"color:#000" class=3D"m_-5042556665519706739m_344026996591664992=
7styled-by-prettify gmail_msg"> </span><span style=3D"color:#606" class=3D"=
m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg">Li=
st</span><span style=3D"color:#660" class=3D"m_-5042556665519706739m_344026=
9965916649927styled-by-prettify gmail_msg">(</span><span style=3D"color:#06=
6" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify g=
mail_msg">1</span><span style=3D"color:#660" class=3D"m_-504255666551970673=
9m_3440269965916649927styled-by-prettify gmail_msg">,</span><span style=3D"=
color:#000" class=3D"m_-5042556665519706739m_3440269965916649927styled-by-p=
rettify gmail_msg"> </span><span style=3D"color:#066" class=3D"m_-504255666=
5519706739m_3440269965916649927styled-by-prettify gmail_msg">2</span><span =
style=3D"color:#660" class=3D"m_-5042556665519706739m_3440269965916649927st=
yled-by-prettify gmail_msg">,</span><span style=3D"color:#000" class=3D"m_-=
5042556665519706739m_3440269965916649927styled-by-prettify gmail_msg"> </sp=
an><span style=3D"color:#066" class=3D"m_-5042556665519706739m_344026996591=
6649927styled-by-prettify gmail_msg">3</span><span style=3D"color:#660" cla=
ss=3D"m_-5042556665519706739m_3440269965916649927styled-by-prettify gmail_m=
sg">)</span><span style=3D"color:#000" class=3D"m_-5042556665519706739m_344=
0269965916649927styled-by-prettify gmail_msg"><br class=3D"gmail_msg"><br c=
lass=3D"gmail_msg"></span><span class=3D"m_-5042556665519706739m_3440269965=
916649927styled-by-prettify gmail_msg"><font color=3D"#000000" class=3D"gma=
il_msg"><div class=3D"m_-5042556665519706739m_3440269965916649927subprettyp=
rint gmail_msg">scala> set.ordering</div><div class=3D"m_-50425566655197=
06739m_3440269965916649927subprettyprint gmail_msg">res3: Ordering[Int] =3D=
scala.math.Ordering$$anon$4@3ff3275b</div><div class=3D"m_-504255666551970=
6739m_3440269965916649927subprettyprint gmail_msg"><br class=3D"gmail_msg">=
</div><div class=3D"m_-5042556665519706739m_3440269965916649927subprettypri=
nt gmail_msg">scala> set.map(identity).ordering</div><div class=3D"m_-50=
42556665519706739m_3440269965916649927subprettyprint gmail_msg">res4: Order=
ing[Int] =3D scala.math.Ordering$Int$@7fa85a55</div></font></span></div></c=
ode></div><div class=3D"gmail_msg"><div class=3D"gmail_msg"><br class=3D"gm=
ail_msg"></div><div class=3D"gmail_msg">I think this can be fixed by provid=
ing a more specific CanBuildFrom instance to be used when mapping between t=
wo sorted collections that contain the same type.</div></div><div class=3D"=
gmail_msg"><br class=3D"gmail_msg"></div><div class=3D"gmail_msg">i.e. Prov=
ide a CanBuildFrom[Sorted[K, _], K, Sorted[K, _]] somewhere that has preced=
ence over the more generic usual CanBuildFrom[CC[_], A, CC[A]]</div><div cl=
ass=3D"gmail_msg"><br class=3D"gmail_msg"></div><div class=3D"gmail_msg">I&=
#39;m not sure how it could be done, but the static overloading resolution =
rules make this possible, I think.</div></div></blockquote></div></div><div=
class=3D"gmail_extra gmail_msg"><div class=3D"gmail_quote gmail_msg"><bloc=
kquote class=3D"gmail_quote gmail_msg" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><span class=3D"m_-5042556665519706739HO=
EnZb gmail_msg"><font color=3D"#888888" class=3D"gmail_msg">
<p class=3D"gmail_msg"></p>
-- <br class=3D"gmail_msg">
You received this message because you are subscribed to the Google Groups &=
quot;scala-language" group.<br class=3D"gmail_msg">
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" clas=
s=3D"gmail_msg" target=3D"_blank">[email protected]=
om</a>.</font></span></blockquote></div></div><div class=3D"gmail_extra gma=
il_msg"><div class=3D"gmail_quote gmail_msg"><blockquote class=3D"gmail_quo=
te gmail_msg" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><span class=3D"m_-5042556665519706739HOEnZb gmail_msg"><font col=
or=3D"#888888" class=3D"gmail_msg"><br class=3D"gmail_msg">
For more options, visit <a href=3D"https://groups.google.com/d/optout" clas=
s=3D"gmail_msg" target=3D"_blank">https://groups.google.com/d/optout</a>.<b=
r class=3D"gmail_msg">
</font></span></blockquote></div></div>
<p class=3D"gmail_msg"></p>
-- <br class=3D"gmail_msg">
You received this message because you are subscribed to a topic in the Goog=
le Groups "scala-language" group.<br class=3D"gmail_msg">
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
d/topic/scala-language/Q5A1TTEZN4Q/unsubscribe" class=3D"gmail_msg" target=
=3D"_blank">https://groups.google.com/d/topic/scala-language/Q5A1TTEZN4Q/un=
subscribe</a>.<br class=3D"gmail_msg">
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:[email protected]" class=3D"gmail_msg"=
target=3D"_blank">[email protected]</a>.<br clas=
s=3D"gmail_msg">
For more options, visit <a href=3D"https://groups.google.com/d/optout" clas=
s=3D"gmail_msg" target=3D"_blank">https://groups.google.com/d/optout</a>.<b=
r class=3D"gmail_msg">
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;scala-language" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">scal=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />
--001a1137b834219fd805426aa279--