本文整理汇总了C++中MyList::pushFront方法的典型用法代码示例。如果您正苦于以下问题:C++ MyList::pushFront方法的具体用法?C++ MyList::pushFront怎么用?C++ MyList::pushFront使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyList
的用法示例。
在下文中一共展示了MyList::pushFront方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initialize
void FixedSet::Initialize(const vector<int>& numbers)
{
size_t sizeOfSecondTables = 0;
size_t tableSize = numbers.size();
MyList<size_t> secondTablesForRebuild;
/* clock_t t1 = clock();*/
secondHashTables.resize(tableSize);
// clock_t t2 = clock();
// cout << (double)(t2 - t1) / CLOCKS_PER_SEC << endl;
generateUniversalHashFunction(tableSize, primeNumber, hash);
for (size_t index = 0; index < tableSize; ++index)
{
size_t hashValue = hash(numbers[index]);
if (!secondHashTables[hashValue].insert(numbers[index]))
{
if (!secondHashTables[hashValue].isNeedRebuild())
{
secondHashTables[hashValue].setRebuild(true);
secondTablesForRebuild.pushFront(hashValue);
}
--sizeOfSecondTables;
}
else
{
++sizeOfSecondTables;
}
}
MyNode<size_t>* it = secondTablesForRebuild.getBegin();
for (; it != 0 && !secondTablesForRebuild.isEmpty(); it = it->next)
{
size_t indexOfSecondHashTable = it->item;
secondHashTables[indexOfSecondHashTable].rebuild();
size_t secondTableSize = secondHashTables[indexOfSecondHashTable].getSize();
sizeOfSecondTables += secondTableSize;
}
if (sizeOfSecondTables > 4 * tableSize)
{
for (size_t index = 0; index < tableSize; ++index)
{
if (!secondHashTables[index].isEmpty())
{
secondHashTables[index].clear();
secondHashTables[index].deleteKeys();
secondHashTables[index].setRebuild(false);
secondHashTables[index].setSize(0);
secondHashTables[index].setEmpty(true);
}
}
Initialize(numbers);
}
}
示例2: insert
bool NonCollisionHashTable::insert(int key)
{
if (empty)
{
setSize(1);
generateUniversalHashFunction(1, primeNumber, hash);
empty = false;
}
keys.pushFront(key);
return simpleInsert(key);
}