HashMap Data Structure


Premium Content - Free Preview

The HashMap in Java uses a Hash function so all its basic operations (adding, removing and finding keys) can be done in constant time. Other languages provide the same capabilities with their Map-equivalent classes. The HashMap's performance is useful for finding optimal solutions to many different problems.

Dictionary Data Structure

Many projects involve matching keys and values so the Map data type is often a natural fit for implementing them:

ApplicationPurposeMapping
Phone bookGet phone numbersMap names to phone numbers
DictionaryDefine wordsMap words to definitions
Internet DNS Lookup Find IP addresses for accessing websites Map domain names to IP addresses

When Not to use HashMaps

Q: If the HashMap can do everything so quickly, why would I ever use another data structure for quickly looking up items?


End of Free Content Preview. Please Sign in or Sign up to buy premium content.

Contact Us
Sign in or email us at [email protected]