title: Find Key in Stl Hash_map
body: <p>I am beginner in c++ and have some problem with hash table. I need a Hash table structure for my program. first I use boost unordered_map. it have all things that I need, but it make my program so slow. then I want to test stl hash_map, but I can't do all thing that I need. this is my first code ( this is sample)</p>
  
  <pre><code>#include &lt;hash_map&gt;
  using namespace std;
  
  struct eqstr
  {
    bool operator()(int s1, int s2) const
    {
      return s1==s2;
    }
  };
  typedef stdext::hash_map&lt; int, int, stdext::hash_compare&lt; int, eqstr &gt; &gt; HashTable;
  
  int main()
  {
    HashTable a;
    a.insert( std::pair&lt;int,int&gt;( 1, 1 ) );
    a.insert( std::pair&lt;int,int&gt;( 2, 2 ) );
    a.insert( std::pair&lt;int,int&gt;( 4, 4 ) );
  //next i want to change value of key 2 to 20
    a[2] =  20;
  //this code only insert pair&lt;2,20&gt; into a, buy when I use boost unordered_map this code                         modify previous key of 2  
  //next I try this code for delete 2 and insert new one
    a.erase(2);//this code does work nothing !!!
  //next I try to find 2 and delete it
    HashTable::iterator i;
    i = a.find(2);//this code return end, and does not work!!!
    a.erase(i);//cause error
  //but when I write this code, it works!!!
    i=a.begin();
    a.erase(i);
  //and finally i write this code
    for (i = a.begin(); i!=a.end(); ++i)
    {
      if (i-&gt;first == 2 )
        break;
    }
    if (i!= a.end())
      a.erase(i);
  //and this code work 
  </code></pre>
  
  <p>but if i want to search over my data, i use array not hash_map, why I can't access, modity and delete from hash_map with o(1)
  what is my mistake, and which hash structure is fast for my program with many value modification in initializing phase. is google sparse_hash suitable for me, if it is, can give me some tutorial on it.
  thanks for any help</p>