I have a large number of interned strings (with a small number of possible values, so it makes sense to intern them) that I want to save in Map(for use as a counter).
TreeMapperforms a comparison at each level of the tree, which, I believe, will be associated with the O (n) character mapping. HashMapwill use the hash for the bucket.
Given that I have a small set of interned strings, which means the link can be used to compare equality or ordering (so neither the hash code nor the value needs to be used), I wonder if there is a well-suited structure
(Or, indeed, more specialized, suitable for counting)
My priorities are speed and compact presentation (I deal with a lot of data).
(To avoid comments of "premature optimization", I process about 200 million elements).
source
share