Is there an easy way to initialize initial capacity and load factor of HashSet in Scala? In Java it's very easy, for example:
public HashSet set = new HashSet(1 << 8, 0.6f)
I'd like to know, if there is any equivalent of this in Scala.
I also know that it's easy to use Javas HashSet instead simply by importing java.util.HashSet, but I'm curious if same is possible with scala.collection.immutable.HashSet
EDIT. I've checked from Scala API and HashSet source code, but didn't find anything useful.
Hashsets comes with two flawors in scala.
mutable.HashSetis pretty like javaHashSetand it hassizeHintmethod which could be used on any (e.g. empty) collection to resize current table.immutable.HashSethas different approach. It is implemented via hash trie algorithm instead of hash table so as JimH mentioned methods likesizeHintare meaningless for it.