I admit I didn't know much before what a Map is living with just the terminology Hash Tables, even when I first Google it I found this https://www.mathworks.com/help/matlab/matlab_prog/overview-of-the-map-data-structure.html#:~:text=A%20Map%20is%20a%20type,indexing%20into%20its%20individual%20elements.&text=These%20keys%2C%20along%20with%20the,key%20and%20its%20corresponding%20value. and thought it's just specific to MATLAB syntax
Then I found https://www.quora.com/What-is-a-map-data-structure-How-does-it-store-data and knew it is a terminology for probably a hash table (they say or a binary search tree, I'm not sure how as an implementation)
& There is a library in C++ for them https://www.udacity.com/blog/2020/03/c-maps-explained.html
https://www.geeksforgeeks.org/map-associative-containers-the-c-standard-template-library-stl/
Now my question how they are actually stored in memory to achieve such a fast indexing on the key as a hash value???
I mean if it's just stored as a 1D array of struct (N* sum of fields size), then it will not function as a hash table in access time. It must add an extra book keeping space( trading space with time) in addition to the user data to add the hash table fast access time
If possible, give me a fn of N, no of elements, say for
type myStruct struct {.
data myData.
myPointer *myStruct
}
map[uint64] *myStruct
I mean it's kind of "not best choice" to use a map to help in traversing a tree, this way I'm allocating a space for 2 trees, and I'm not sure the running time requirements will follow my tree kind that I worked so hard to think of, or the kind of tree the C++ implementation used???
if [a map is] just stored as a 1D array of struct (N* sum of fields size), then it will not function as a hash table in access time
Please elaborate: What in an implementation of a hash table makes that not a 1D array? $\endgroup$