Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preferred Scala collection for progressively removing random items?

I have an algoritm which takes many iterations, each of which scores items in a collection and removes the one with the highest score.

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?

like image 442
Duncan McGregor Avatar asked Jan 19 '23 12:01

Duncan McGregor


1 Answers

You could consider a DoubleLinkedList, which has a convenient remove() method to remove the current list cell.

like image 72
Jean-Philippe Pellet Avatar answered Feb 13 '23 16:02

Jean-Philippe Pellet