user2260218
user2260218

Reputation:

When would I ever not use a hashmap?

Is there anytime when using a hashmap isn't definitely the way to go? In general, it seems like hashmaps out do trees, linked lists, and the like. Is there ever a time to not use a hash?

Upvotes: 3

Views: 1846

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201477

If all of your object keys have the same hashCode, or you don't even have some kind of key, or you have null keys, or your algorithm or program doesn't require a hashmap. For example, how would you implement a graph with a hashmap? How about a stack? A set?

Upvotes: 3

Related Questions