Re: HashMap Capacity Argument.



You can back this out from the load factor. The load factor, for the
purposes of this post, represents the maximum percentage of the
capacity of the HashMap that may be populated. The HashMap will be
resized when its size exceeds a threshold value, computed by:

threshold = (int)(capacity * loadFactor);

The default load factor is .75f. Given this, lets say you know you're
storing at most 100 keys. You can then construct your HashMap by the
following:

(1) hm = new HashMap( 134 ); // because (100 / 134) < .75

or in general

(2) hm = new HashMap( c, f ); // where ( 100 / c ) < f

Check the source code for HashMap for futher insight, but I think this
is info enough to answer your post.

-Fred

.



Relevant Pages

  • Text parsing and substitution
    ... parse the line, ... load a hashmap with the key, ... I was thinking this sort of logic but a little apprehensive how elastic ...
    (comp.lang.perl.misc)
  • problem when try to store xmldom into hashmap
    ... ANd i call loadxml many times to load different xml string and each time i ... store m_pDocPtr ... in to hashmap as value with some key say number.. ...
    (microsoft.public.vc.mfc)
  • problem when try to store xmldom into hashmap
    ... ANd i call loadxml many times to load different xml string and each time i ... store m_pDocPtr ... in to hashmap as value with some key say number.. ...
    (microsoft.public.vc.stl)
  • problem when try to store xmldom into hashmap
    ... ANd i call loadxml many times to load different xml string and each time i ... store m_pDocPtr ... in to hashmap as value with some key say number.. ...
    (microsoft.public.win32.programmer.ole)
  • Re: Battery level tester.
    ... > You can't simply relate voltage to usable capacity remaining, ... When the load is dynamic, ... They are voltage devices and only run two leads to the battery. ... These are probably the gold standard gauges used for EVs. ...
    (sci.electronics.design)