I want to store huge amounts of Strings in a Map<String, MagicObject>
, so that the MagicObjects
can be accessed quickly. There are so many entries to this Map that memory is becoming a bottleneck. Assuming the MagicObjects
can't be optimized, what is the most efficient type of map I could use for this situation? I am currently using the following:
gnu.trove.map.hash.TCustomHashMap<byte[], MagicObject>
If your keys are long enough and have a lot of long enough common prefixes then you can save memory by using a trie (prefix tree) data structure. Answers to this question point to a a couple of Java implementations of trie.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With