要使用哪个 Scala 可变列表? [英] Which scala mutable list to use?
问题描述
我想在 Scala 中使用可变列表.我可以从中选择
I want to use a mutable list in Scala. I can chose from
scala.collection.mutable.DoubleLinkedList
scala.collection.mutable.LinkedList
scala.collection.mutable.ListBuffer
scala.collection.mutable.MutableList
哪个很好,但什么是标准"、推荐、惯用的 Scala 方式?我只想使用一个列表,我可以在后面添加内容.
Which is nice, but what is the "standard", recommended, idiomatic scala way? I just want to use a list that I can add things to on the back.
就我而言,我使用的是 HashMap,其中列表"(我的意思是一般意义上的)将在价值方面.然后,我从文件中读取一些内容,对于每一行,我想在哈希图中找到正确的列表并将值附加到列表中.
In my case, I am using a HashMap, where the "lists" (I am meaning it in general sense) will be on value side. Then, I am reading something from a file and for every line, I want to find the right list in the hashmap and append the value to the list.
推荐答案
为了读者访问这个老问题:文档的 具体可变集合类 部分概述了可变列表类,包括何时使用哪个类的说明.
For the sake of readers visiting this old question: The documentation's Concrete Mutable Collection Classes section has an overview of mutable list classes, including explanations on when to use which one.
这篇关于要使用哪个 Scala 可变列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!