要使用哪个 Scala 可变列表? [英] Which scala mutable list to use?

查看:40
本文介绍了要使用哪个 Scala 可变列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是没有Scala可变列表

我想在 Scala 中使用可变列表.我可以从中选择

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

哪个很好,但什么是标准"、推荐、惯用的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆