本文整理汇总了C++中ListElement::getElemCounter方法的典型用法代码示例。如果您正苦于以下问题:C++ ListElement::getElemCounter方法的具体用法?C++ ListElement::getElemCounter怎么用?C++ ListElement::getElemCounter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListElement
的用法示例。
在下文中一共展示了ListElement::getElemCounter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebuildTable
void HashTable::rebuildTable(unsigned int newSize, HashFunction *hashFunct)
{
List **oldTable = table;
unsigned int oldSize = hTsize;
hTsize = newSize;
createTable();
collisions = 0;
maxCollLength = 0;
LoadFactor = 0;
elemQuantity = 0;
delete hash;
hash = hashFunct;
for (unsigned int i = 0; i < oldSize; i++)
{
if (oldTable[i] != NULL && !oldTable[i]->isEmpty())
{
ListElement *temp = oldTable[i]->getHead();
while (temp->getNext() != NULL)
{
add(temp->getStr(), temp->getElemCounter());
temp = temp->getNext();
}
add(temp->getStr(), temp->getElemCounter());
}
}
for (int i = 0; i < hTsize; i++)
delete oldTable[i];
delete[] oldTable;
}
示例2: add
void List::add (string str, unsigned int quantity)
{
if (size == 0)
{
ListElement *temp = new ListElement(str);
head = temp;
tail = temp;
head->setElemCounter(temp->getElemCounter() + quantity);
size++;
}
else
{
ListElement *tmp = head;
while (tmp->getNext() != NULL)
{
if (tmp->getStr() == str)
{
tmp->setElemCounter(tmp->getElemCounter() + quantity);
return;
}
tmp = tmp->getNext();
}
if (tail->getStr() == str)
{
tmp->setElemCounter(tmp->getElemCounter() + quantity);
return;
}
else
{
ListElement *temp = new ListElement(str, tail, NULL);
temp->setElemCounter(temp->getElemCounter() + quantity);
tail->setNext(temp);
tail = temp;
size++;
}
}
}