title: Returning individual index values of a vector
body: <p>I'm tasked with hashing a vector and returning the hashed index values of each element within the vector. My code is returning the same value for every element however, but I feel like I just need to move something around to fix the problem. What I have so far:</p>
  
  <pre><code>void HashNames::hash(string fileName)
  {
      ifstream infile(fileName);
      string tmp;
      for (int i = 0; i &lt; 1002; i++)
      {
          infile &gt;&gt; tmp;
          this-&gt;nameList.push_back(tmp);
          for (int i = 0; i &lt; nameList.size(); i++)
          {
              this-&gt;index = djbHash(tmp, 53);
          }
      }
  }
  int HashNames::djbHash(string data, int table)
  {
      int hashVal = 5381;
      for (int i = 0; i &lt; data.length(); i++)
      {
          hashVal *= 33;
          hashVal += static_cast&lt;int&gt;(data[i]);
      }
      hashVal %= table;
      return abs(hashVal);
  }
  void HashNames::printNames()
  {
      for (int i = 0; i &lt; this-&gt;nameList.size(); i++)
      {
          cout &lt;&lt; this-&gt;index &lt;&lt; ": " &lt;&lt; this-&gt;nameList[i] &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>And what the class looks like:</p>
  
  <pre><code>class HashNames
  {
  private:
      int index;
      vector&lt;string&gt; nameList;
      int djbHash(string data, int table);
  public:
      void hash(string fileName);
      void printNames();
  };
  </code></pre>