title: Rehashing a hash table comprised of a vector of lists C++
body: <p>So I have implemented a hash table storing pointers. I implemented it as a <code>vector</code> of <code>lists</code>. Along the lines of <code>std::vector&lt;std::list&lt;Sequence*&gt; &gt; hashTable;</code>. I have implemented everything and it works fine. My only problem arises when I try to rehash the hash table. The hash table uses separate chaining to resolve collisions, hence my vector of lists.</p>
  
  <p>Using the debugger, I have found that my loop to rehash is hanging on the while loop and causing an infinite loop. It constantly reads from the first index of my old vector. I am new to this and I am not sure of the proper way to rehash this table. I tried to research and found not many references to this implementation of a hash table, much less rehashing one. Here is my implementation.</p>
  
  <pre><code>void HashTable::rehash(int oldSize){
      int tempSize = 2 * oldSize;
      int newSize = HashTable::findPrime(tempSize);
      std::vector&lt;std::list&lt; Sequence*&gt; &gt; newHashTable;
      newHashTable.resize(newSize);
      tableSize = newSize;
      for(int i = 0; i &lt; oldSize; i++){
          auto iter = hashTable[i].begin();
          while(iter != hashTable[i].end()){
              if((*iter) != nullptr){
                  std::string tempString = (*iter)-&gt;getKey();
                  int hashIndex = hashFunction(tempString);
                  newHashTable[hashIndex].push_front(*iter);
              }
          }
      }
      hashTable = newHashTable;
  }
  </code></pre>
  
  <p>I feel like it is a simple error, I am just not seeing it. Or am I completely going about this the wrong way?</p>