I couldn’t understand what does the operator “<<” means in the following code.
long hashString(char* key)
{
int n = strlen(key);
long h = 0;
for(int i=0; i<n; i++)
{
h = (h << 2) + key[i];
}
return abs(h % tablesize);
}
It’s the left shift operator. It shifts the value left by 2 bits, effectively multiplying it with 2 to the power of 2 (the shift amount).
Is the same as: