示例#1
0
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();
    }
}
示例#2
0
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 << "\"";
//    }
}
示例#3
0
 bool		operator==(const Pair &p)
 {
   if (_Key == p.getKey() && _Val == p.getValue())
     return 1;
   return 0;
 }
示例#4
0
void HashTable::remove(Pair pair) {
    int index = hashFunction(pair.getKey());
    // Will throw ListException::ElementNotFound if pair is not found
    data[index].remove(pair);
}