Which scala mutable list to use?

后端 未结 4 1066
梦如初夏
梦如初夏 2020-12-13 13:33

This is a followup question to No Scala mutable list

I want to use a mutable list in Scala. I can chose from

  • scala.collection.mutable.DoubleLinkedList
4条回答
  •  Happy的楠姐
    2020-12-13 13:58

    I just want to use a list that I can add things to on the back.

    Then choose something that implements Growable. I personally suggest one of the Buffer implementations.

    I stay away from LinkedList and DoubleLinkedList, as they are present mainly as underlying implementation of other collections, but have quite a few bugs up to Scala 2.9.x. Starting with Scala 2.10.0, I expect the various bug fixes have brought them up to standard. Still, they lack some methods people expect, such as +=, which you'll find on collections based on them.

提交回复
热议问题