Tuesday 20 October 2015

Why java's TreeMap does not allow an initial size?

Why Java's TreeMap does not allow an initial size?

HashMap reallocates its internals as the new one gets inserted while in TreeMap does not reallocate nodes on adding new ones.

Thus, the size of the TreeMap dynamically increases if needed, without shuffling the internals. So it is meaningless to set the initial size of the TreeMap.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...