title: How do i program a Double hash implementation meant for strings?
body: <p>Hello everyone first time here but i'd like to start by first asking if my understanding of double hashing is correct.</p>
  
  <p>Double hashing works by first implementing a hash function then checking to see if that spot is open. if the current spot is not open then using a second hash function determine another spot and then multiply it by the current attempt and then add it to the index spot that was determined by the first hashing algorithm.</p>
  
  <p>the current code i'd have is:</p>
  
  <pre><code>unsigned int findPos(hashedObj&amp; x)
  {
      int offset = 1;
      int iteration = 0;
      unsigned int originalPos = myhash1( x );
      unsigned int index = originalPos;
      unsigned int secondPos = myhash2( x );
      while( array[ index ].info != EMPTY &amp;&amp; array[ index ].element != x )
      {
          iteration = offset++ * secondPos;
          if ( ( originalPos + iteration ) &gt; array.size( ) )
              index = ( originalPos + iteration ) % array.size( );
          else
              index = originalPos + iteration;
      }
      return ( index );
  }
  
  unsigned int hash1( const string&amp; key, const int Tsize )
  {
      //start the hashvalue at 0
      unsigned int hashVal = 0;
  
      //cout&lt;&lt;" the size of the table is: "&lt;&lt; Tsize &lt;&lt;endl;
  
      //add the ascii value for every word to hashval, multiply by 37 each time
      for ( int i = 0; i &lt; key.length(); i++ )
          hashVal = 37 * hashVal + key[ i ];
      //mod hashval so it remains smaller than the table size
      hashVal %= Tsize;
  
      //return the itemes index value
      return hashVal;
  }
  </code></pre>
  
  <p>i just realized i didnt include my second hash function</p>
  
  <pre><code>unsigned int hash2( const string&amp; key, const int Tsize )
  {
  //store the sum of ascii numerical values
  int hashVal = 0;
  
  //add the values of all chars while multiplying each one with a prime number
  for ( int i = 0; i &lt; key.length(); i++ )
      hashVal = 29 * hashVal + key[ i ];
  
  //mod the hashed value with a prime smaller than the table size, subtract that number
  //with the prime just used and return that value
  unsigned int index = 44497 - ( hashVal % 44497 );
  
  return index;
  }
  </code></pre>
  
  <p>it may not look like it but in the real deal tsize is being called correctly.</p>