If the list of hash keys for a hash function is known and immutable, it is possible to generate a perfect hash function. A Enum in Java is a list of known and immutable elements. Therefor it should be possible to implement the EnumMap as a perfect hash. Is this currently (1.7) done in Java?
No. EnumMap
doesn't use hashing. It uses the enum
ordinal values as indexes into an array of the value type.
Reference: