0
$\begingroup$

Forgive me/delete this question if it doesn't qualify as Computer Science:

I've always wondered about the relationship between Map the data structure and map() the function. I know they are two different things. Why share the name?

$\endgroup$
0
$\begingroup$

Well, I am only a beginning MSc student in computerscience but if if followed the classes correctly the purpose of a hash is to create some memory space, let say this memory space is 10 adresses big. With a hashmap, every value you put in the hashmap gets coupled with a key. That key will first be mapped by a hashfunction to produce a unique number. That number is within the range of possible adresses in the vector. $ f: A \mapsto B $ with A the collection of possible keys and B a collection of possible adresses. Mathematically speaking this is a mapping. The value gets then saved to that adress. Now it is possible that you want to save more values than the vector allows or the hashfuntion is not completely one on one (that is every y has a unique x value it corresponds to) In that case you wil need to make the vector longer and remap every value within the vector or you reshash the value from the hashfunction with that same same value it has returned (usualy slightly edited to avoid all values being at the same place in the vector) as the parameter to find a new adress that wasn't used before. There are a number of other techniques involved and other methods but that is beside the point. Long story short. This mapping of key values is, i believe, the reason it is called a hashmap.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.