We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is a Hashmap?

By Jessica Reed
Updated: May 17, 2024
Views: 8,938
Share

In computer science, a hashmap or hash table is a form of structuring data so that each piece of data is linked to a unique identification number or symbol. This allows easy retrieval, especially from a large database containing thousands of entries. The hashmap is not a specific part of the program, but rather refers to a form of data organization that assigns each item, known as a key, in the database to a value that stands for that item. The hash function is the part of the program which links keys to their values.

Phone books serve as an excellent example of a hashmap. The way the phone book is laid out represents the hashmap structure. It focuses on linking different values together and linking only one value to one other corresponding term, or phone number. The names in the phone book are the keys and the phone numbers are the values associated with them. Every person in the book is assigned a different number and no two are alike.

Post office boxes also serve as a metaphor for the hashmap. Every person has a key to a single box. The box can hold multiple pieces of information — bills, letters, postcards — all intended for the individual who has the key to the box. When the correct key is inserted in, or matched to, the correct box, it opens to reveal its contents.

Perfectly functioning hashmaps would link one key to one memory "box" in a computer database. Unfortunately, a factor known as hash collision can occur, where two keys go to the same box. This happens when a large amount of data is entered and there are not enough "boxes" to accommodate it all.

Unlike a phone book or a post office box, hashmaps include a third element in addition to the key and the value or box it matches. It also includes a hash function. A person knows which post office box is hers, but a computer must be told which key goes to which box. The hash function looks at the key, translates it into a series of numbers or code, and links it to the box that contains the corresponding code. The name of the key, such as "Mary," is only there so it is easier for people to interpret, while the actual code is a string of numbers meant for the computer to read.

Share
WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.

Editors' Picks

Discussion Comments
Share
https://www.wisegeek.net/what-is-a-hashmap.htm
Copy this link
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.