本文介绍了用于逐步删除随机项目的首选 Scala 集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个需要多次迭代的算法,每次迭代都会对集合中的项目进行评分并删除得分最高的项目.
I have an algoritm which takes many iterations, each of which scores items in a collection and removes the one with the highest score.
我可以用初始填充填充 Vector
,不断将其替换为 var
,或者选择可变集合作为 val
.哪个可变集合最符合要求?
I could populate a Vector
with the initial population, continually replacing it as a var
, or choose a mutable collection as a val
. Which of the mutable collections would best fit the bill?
推荐答案
您可以考虑使用 DoubleLinkedList
,它有一个方便的 remove()
方法来删除当前列表单元格.
You could consider a DoubleLinkedList
, which has a convenient remove()
method to remove the current list cell.
这篇关于用于逐步删除随机项目的首选 Scala 集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!