As i understood correctly , implementing hash table , is calculating index based on inputed string , and returning it directly making it simple key - value storage.
So simple hash function could look something like
int hash( string name ){
int index = 0;
int hash = 0;
for ( int i = 0; i < name.length() ;i++){
hash += (int)name[i];
}
index = sizeOfArray % hash;
}
SizeOfArray is array of pointers with predefined size. If this index does not exists it creates it. But how i implement it with vectors?
Vector does not have predefined size. An they grow automaticly. So calling sizeOfArray % hash will change everytim vector will grow.
What is logic behind has tables? Whats the best method to calculate index even with growing vector / array?
std::unordered_map.hash % sizeOfArray.