斯卡拉排序indexedseq到位 [英] scala sort indexedseq in place
问题描述
如何在Scala中对IndexedSeq
进行排序? API函数在哪里?
How do you sort an IndexedSeq
in place in scala? Where's the API function?
推荐答案
当前没有可对其进行就地排序的东西.
Currently there is nothing to sort them in-place.
如果确实需要,可以将IndexedSeq
转换为Array[AnyRef]
并从Java使用Arrays.sort
(您必须转换为Array[AnyRef]
,因为Scala的数组不像Java的协变).
If you really need that it would be possible to convert the IndexedSeq
to an Array[AnyRef]
and use Arrays.sort
from Java (you have to cast to Array[AnyRef]
, because Scala's arrays are not covariant like Java's).
几个星期前,有趣的是,有人在讨论如何在Scala的可变集合中添加就地版本的操作,例如map,filter和sort.
Interestingly a few weeks ago there was a discussion about adding in-place versions of operation like map, filter and sort to Scala's mutable collections.
我希望在2.9版并行集合之后,这可以成为进一步改善Scala集合的清单上的下一个工作项目.
I hope after the 2.9 release of parallel collections this could be the next work item on the list to further improve Scala's collection.
如果人们提高声音以支持它(或提供可行的实现方式):-),这并没有什么坏处.
It doesn't hurt if people would raise their voice in support of it (or supply a working implememtation) :-).
这篇关于斯卡拉排序indexedseq到位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!