We use HashMap<Integer, SomeType>()with over a million entries. I find that big.
But integers are their own hash code. Could you save memory with, say, IntegerHashMap<Integer, SomeType>()that uses a special one Map.Entry, using int directly instead of a pointer to an object Integer? In our case, this will save the 1000000x memory needed for the object Integer.
Any errors in my mind? Too special for general interest? (at least exists EnumHashMap)
add1. The first general parameter is IntegerHashMapused to make it close to other implementations Map. Of course, this can be dropped.
add2. The same should be possible with other cards and collections. For example ToIntegerHashMap<KeyType, Integer>, IntegerHashSet<Integer>etc.
source
share