Closed TheMode closed 1 year ago
Presently you can have a subclass that exposes a method using rehash(), exactly like ensureCapacity() does. putAll() will also try to increase capacity, so you should that for batch insertion.
I don't see particular reasons not to make the method public. Does anybody have a different opinion? @incaseoftrouble @techsy730 ?
Presently you can have a subclass that exposes a method using rehash(), exactly like ensureCapacity() does. putAll() will also try to increase capacity, so you should that for batch insertion.
These could work, but far from being convenient in my case: https://github.com/Minestom/Minestom/blob/708307dbdec3671592fdfd3c06b4cd33a1b41cb8/src/main/java/net/minestom/server/ServerProcessImpl.java#L273-L275 as I would also need to make my own lazy Map
, which may be counterproductive and add more overhead.
Having the method exposed would definitely be welcome.
I also need such behaviour. I create the map in one class and in another class, I got collection future size before doing all puts. So I cannot init the class with the right size. Ability to set call ensureCapacity would have help me in this case.
Done in 85bb33b1bfde34dac21005037951b615268f0083. Let me know if it works for you...
Useful to avoid unnecessary resizing on batch insertion