3 ms·
In the case of Java, there is a lot of inefficiency in the standard hash table in the form of Entry<T, K> objects for making it a bit nicer to use. There is als
by RyanZAG 13y ago
In the case of Java, there is a lot of inefficiency in the standard hash table in the form of Entry<T, K> objects for making it a bit nicer to use. There is also a lot of extra state stored for some of the extra features offered. Everything has a cost. If you just need a straight Int->Int or Int->Object map, there are a lot of ways to make it far more efficient.
The standard library doesn't contain these, because in 99% of apps, the actual performance of the hash table is a very minor part and a small bit of overhead for added convenience is worth it. However in a program where the hashmap is the key point, you'd obviously choose to optimize it to fit your goals.