本文整理汇总了C++中MyList::getBegin方法的典型用法代码示例。如果您正苦于以下问题:C++ MyList::getBegin方法的具体用法?C++ MyList::getBegin怎么用?C++ MyList::getBegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyList
的用法示例。
在下文中一共展示了MyList::getBegin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebuild
void NonCollisionHashTable::rebuild()
{
clear();
setSize(keys.getSize() * keys.getSize());
generateUniversalHashFunction(table.size(), primeNumber, hash);
if (!keys.isEmpty())
{
MyNode<int>* it = keys.getBegin();
while (it != 0)
{
if (!simpleInsert(it->item))
{
it = keys.getBegin();
clear();
generateUniversalHashFunction(table.size(), primeNumber, hash);
}
else
{
it = it->next;
}
}
}
needRebuild = false;
}
示例2: 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);
}
}
示例3: clear
void NonCollisionHashTable::clear()
{
if (!keys.isEmpty())
{
MyNode<int>* it = keys.getBegin();
bool empty = table[hash(it->item)].second;
for (; it != 0 && !empty; it = it->next)
{
empty = table[hash(it->item)].second;
table[hash(it->item)] = make_pair<int, bool>(0, true);
}
}
}