Chaitanya
Chaitanya

Reputation: 3638

Initial size of mutable Hashmap in scala

As in Java, whenever we declare a map like

Map<String,String> myMap = new HashMap();

then a hashtable of size 16 is created initially with a load factor of 0.75.

Similarly, what will be the initial size and load factor of scala mutable hashmap ? Will be similar to java wherein a hashtable of default size of 16 is created ?

Upvotes: 0

Views: 529

Answers (1)

Duong Nguyen
Duong Nguyen

Reputation: 850

Yes, it's the same with Java HashMap where initial size is 16 and load factor of 75%. They're all defined as per scala.collection.mutable.HashTable.

private[collection] final def defaultLoadFactor: Int = 750 // corresponds to 75%
...
protected def initialSize: Int = 16

Upvotes: 3

Related Questions