void HashTable::insert(Pair pair) { int index = hashFunction(pair.getKey()); data[index].insertHead(pair); int listSize = data[index].getSize(); // If the hash table is overloaded if (listSize >= loadFactor) { resize(); } }
void Element::printAttributes(ostream &out) { for (int i = 0; i < attributes.size(); ++i) { Pair* p = attributes[i]; out << ' ' << p->getKey(); out << "=\"" << p->getValue() << "\""; } // map<string, string>::iterator i; // for (i = attributes.begin(); i != attributes.end(); ++i) { // out << ' ' << i->first << "=\"" << i->second << "\""; // } }
bool operator==(const Pair &p) { if (_Key == p.getKey() && _Val == p.getValue()) return 1; return 0; }
void HashTable::remove(Pair pair) { int index = hashFunction(pair.getKey()); // Will throw ListException::ElementNotFound if pair is not found data[index].remove(pair); }