Size of a hash map

The documentation
states that value member named “size” is “the size of this mutable hash map” .
Isn’t that a misleading (or at least unhelpful) description? There are several “sizes” which one might want to know, and this documentation does not indicate which one it is. Size could mean the amount of allocated space, the size of the underlying sparse array, the number of key->value pairs stored in the hash map, or potentially several more.

In my option, the documentation would be more helpful if it really indicated more than what is obvious given the name of the value member.

BTW, which one is it?

It’s the number of keys in the map

1 Like

The docs are pretty clear about collection .size() method - it is intended to indicate the number of elements that would be emitted from the collection’s iterator.

Brian Maso

OK, well I understand now. But when I first read the spec, I was expecting size to be the actual size, meaning the number of spaces allocated, and the count to be the number of keys.

I have typically seen the word “capacity” used to represent the amount of space allocated.

Pull requests with doc improvements are always welcome, but be sure you’re checking the current Scaladoc — the link you posted was to an ancient Scala version (2.9).

1 Like