0

Can someone please tell me how I would wrap my array. Lets say that it is of size 10. What I want it to do is count the number of letters in the name then mod it into the array (This is working properly). If a name has the same number of letters then it just looks at the next spot. So I need my array to wrap around meaning that if the 10th spot is filled then it would look at the 1st spot in the array. I know that you can do this by using the mod function but am not sure how.Here is my HashTable

```
template <class T>
hashTable<T>::hashTable(int Size = 10)
{
value_arr = new T[Size];
key_arr = new string[Size];
status_arr = new int[Size];
HTableSize = Size;
// hashIndex + 1 % Size //Wrap around
for (int i = 0; i < Size; i++)
status_arr[i] = 0;
}
```

Here is my Hash Function

```
template <class T>
int hashTable<T>::hashFunction(string key)
{
return (key.length() - 1) % HTableSize;
}
```

Here is my add function

```
template <class T>
void hashTable<T>::add(string key, const T &value)
{
//while (exists() != true)
//int hashIndex;
hashIndex = hashFunction(key);
while (status_arr[hashIndex] == 1)
{
hashIndex ++;
}
if (status_arr[hashIndex] !=1)
{
key_arr[hashIndex] = key;
value_arr[hashIndex] = value;
status_arr[hashIndex] = 1;
}
}
```

Thanks for the help!