5 HashTable(size_type size):
13 hash(const std::string& val)
16 for (unsigned char* p = (unsigned char*)val.c_str(); *p != '\0';
21 return h % table.size();
27 /// Functor para encontrar pares con clave igual
30 const std::string& clave;
31 ClaveIgualA(const std::string& clave): clave(clave) {}
32 bool operator()(const HashTable::pair_type& par)
34 return par.first == clave;
42 operator[](const std::string& key)
44 size_type pos = hash(key);
45 list_type::iterator par = std::find_if(table[pos].begin(),
46 table[pos].end(), ClaveIgualA(key));
47 if (par == table[pos].end()) // No encontrada
50 table[pos].push_back(pair_type(key, 0));
51 return table[pos].back().second;
53 else return par->second;