data structures - How are hashtables (maps) stored in memory? -


this question hashtables, might cover other data structures such linked lists or trees.

for instance, if have struct follows:

struct data  {    int value1;    int value2;    int value3; } 

and each integer 4-byte aligned , stored in memory sequentially, key , value of hash table stored sequentially well? if consider following:

std::map<int, string> list; list[0] = "first"; 

is first element represented this?

struct listnode {    int key;    string value; } 

and if key , value 4-byte aligned , stored sequentially, matter next pair stored?

what node in linked list?

just trying visualize conceptually, , see if same guidelines memory storage apply open-addressing hashing (the load under 1) vs. chained hashing (load doesn't matter).

it's highly implementation-specific. , not referring compiler, cpu architecture , abi, implementation of hash table. hash tables use struct contains key , value next each other, have guessed. others have 1 array of keys , 1 array of values, values[i] associated value key @ keys[i]. independent of "open addressing vs. separate chaining" question.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -