Top "Scala-collections" questions

Collection library for Scala Programming Language

How can I find the index of the maximum value in a List in Scala?

For a Scala List[Int] I can call the method max to find the maximum element value. How can I …

scala indexing max scala-collections
Scala Sets contain the same elements, but sameElements() returns false

Whilst working through the Scala exercises on Iterables, I encountered the following strange behaviour: val xs = Set(5,4,3,2,1) val ys = Set(1,2,3,4,5) …

scala scala-collections
Convert java.util.HashMap to scala.collection.immutable.Map in java

I'm using some Scala library from my Java code. And I have a problem with collections. I need to pass …

java scala scala-collections
Use-cases for Streams in Scala

In Scala there is a Stream class that is very much like an iterator. The topic Difference between Iterator and …

scala stream scala-collections
how to sort a scala.collection.Map[java.lang.String, Int] by its values?

How would you sort a scala.collection.Map[java.lang.String, Int] by its values (so on the Int)? What …

sorting scala scala-collections
Scala Map to Java HashMap

I have a Scala function f(s1: String, s2: String): Map[String,String] I want to allow a colleague coding …

scala scala-collections scala-java-interop
Difference between MutableList and ListBuffer

What is the difference between Scala's MutableList and ListBuffer classes in scala.collection.mutable? When would you use one vs …

scala scala-collections
idiomatic "get or else update" for immutable.Map?

What is the idiomatic way of a getOrElseUpdate for immutable.Map instances?. I use the snippet below, but it seems …

scala scala-collections
How to convert from from java.util.Map to a Scala Map

A Java API returns a java.util.Map<java.lang.String,java.lang.Boolean>;. I would like to …

scala map scala-collections language-interoperability
How to get a random element from a Set in Scala

For any given set, for instance, val fruits = Set("apple", "grape", "pear", "banana") how to get a random element from …

scala random collections set scala-collections