本文整理汇总了C++中AvlTree::insertValue方法的典型用法代码示例。如果您正苦于以下问题:C++ AvlTree::insertValue方法的具体用法?C++ AvlTree::insertValue怎么用?C++ AvlTree::insertValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AvlTree
的用法示例。
在下文中一共展示了AvlTree::insertValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
//Assignment 4 part 1
const int arraySize = 100000;
int* arr = ArraySearcher::generateArray(arraySize);
cout << "Results for searches:" << endl;
auto start = Clock::now(); //start time
for (int i = 0; i < arraySize; i++)
ArraySearcher::sequentialSearch(arr, i, arraySize);
auto end = Clock::now(); //end time
cout << "Sequential: " << DURATION << " milliseconds" << endl;
start = Clock::now();
for (int i = 0; i < arraySize; i++)
ArraySearcher::binarySearch(arr, i, arraySize);
end = Clock::now();
cout << "Binary: " << DURATION << " milliseconds" << endl;
_getch();
cout << "~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
/* Assignment 4 - Part 2 */
AvlTree tree;
/* Fill tree with words from dictionary */
ifstream dictionary("../resources/dictionary.txt");
if (dictionary.is_open())
{
string line;
while (getline(dictionary, line))
{
tree.insertValue(line);
}
dictionary.close();
}
else
{
cout << "Couldn't open file!" << endl;
}
/* Print the full tree */
cout << "Full dictionary avl tree: " << endl << endl;
tree.printTree();
cout << endl << endl << endl;
/* Checking misspelled words */
ifstream mispelled("../resources/mispelled.txt");
if (mispelled.is_open())
{
cout << "Mispelled words: " << endl;
string data;
getline(mispelled, data);
char* delim = " ,.!?()#&1234567890\"";
char* buffer = new char[data.length() + 1];
strcpy(buffer, data.c_str());
char* word;
word = strtok(buffer, delim);
while (word != NULL)
{
int i = 0;
while (word[i])
{
word[i] = tolower(word[i]);
i++;
}
if (!tree.searchTree(word))
{
cout << word << endl;
}
word = strtok(NULL, delim);
}
mispelled.close();
}
else
{
cout << "Couldn't open file!" << endl;
//.........这里部分代码省略.........