Why Doesn't Java's TreeMap Allow an Initial Size?
Loading 1 000 000 numbers takes 2 seconds to load into a treemap (binary
search tree), but takes milliseconds to load into a hashmap (in java).
The only difference between the two is that I can see is I can set a
hashmap's initial size so it does not constantly need to re-size.
Am I wrong to assume a TreeMap's array's initial size should be able to be
set? Is there a different reason that it is so slow?
Is there a logical reason for why one cannot set TreeMap's, or any generic
binary search tree's, size or is this wrong?
No comments:
Post a Comment