本文整理汇总了C++中ItemType::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemType::toString方法的具体用法?C++ ItemType::toString怎么用?C++ ItemType::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemType
的用法示例。
在下文中一共展示了ItemType::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
clock_t start = clock();
int const DELETE_CT = 2;
int const PRINTSIZE = 5;
int const HOWMANY = 20; // How many values to read from each file. If HOWMANY = 0, read all values.
// SkewHeap pq1("SkewHeap PQ1");
// LeftistHeap pq1("Leftist PQ1");
/*PQHeap pq1("Heap PQ1", 6000);
PQHeap pq2("Heap PQ2", 6000);
PQHeap pq3("Heap PQ3", 6000);
PQHeap pq4("Heap PQ4", 6000);
PQHeap pq5("Heap PQ5", 6000);
PQHeap pq6("Heap PQ6", 6000);*/
SkewHeap pq1("SkewHeap PQ1");
SkewHeap pq2("SkewHeap PQ2");
SkewHeap pq3("SkewHeap PQ3");
SkewHeap pq4("SkewHeap PQ4");
SkewHeap pq5("SkewHeap PQ5");
SkewHeap pq6("SkewHeap PQ6");
/*Leftist pq1("LeftistHeap PQ1");
Leftist pq2("LeftistHeap PQ2");
Leftist pq3("LeftistHeap PQ3");
Leftist pq4("LeftistHeap PQ4");
Leftist pq5("LeftistHeapPQ5");
Leftist pq6("LeftistHeapPQ6");/**/
ifstream fin;
fin.open("Prog5In.txt");
assert(fin);
insertNext(pq1, fin, HOWMANY);
insertNext(pq2, fin, HOWMANY);
insertNext(pq3, fin, HOWMANY);
insertNext(pq4, fin, HOWMANY);
insertNext(pq5, fin, HOWMANY);
insertNext(pq6, fin);
cout << pq1.toString(PRINTSIZE);
ofstream fout;
fout.open("prog5out.txt");
cout << pq1.toString(PRINTSIZE);
for (int ct = 0; ct < DELETE_CT && !pq1.isEmpty(); ct++){
ItemType big = pq1.deleteMax();
fout << " ** DELETED " << big.toString() << endl;
cout << " ** DELETED " << big.toString() << endl;
cout << pq1.toString(PRINTSIZE);
};
for (int ct = 0; ct < DELETE_CT && !pq2.isEmpty(); ct++) {
ItemType big = pq2.deleteMax();
fout << " ** DELETED " << big.toString() << endl;
cout << " ** DELETED " << big.toString() << endl;
};
cout << "Before merge \n" << pq1.toString(PRINTSIZE) << endl;
fout << "Before merge \n" << pq1.toString(PRINTSIZE) << endl;
cout << "Before merge \n" << pq2.toString(PRINTSIZE) << endl;
fout << "Before merge \n" << pq2.toString(PRINTSIZE) << endl;
pq1.merge(&pq2);
cout << "After merge \n" << pq1.toString(PRINTSIZE) << endl;
fout << "After merge \n" << pq1.toString(PRINTSIZE) << endl;
cout << "After merge \n" << pq2.toString(PRINTSIZE) << endl;
fout << "After merge \n" << pq2.toString(PRINTSIZE) << endl;
pq3.merge(&pq4);
cout << "After merge 3 and 4 \n" << pq3.toString(PRINTSIZE) << endl;
pq5.merge(&pq6);
cout << "After merge 5 and 6 \n" << pq5.toString(PRINTSIZE) << endl;
pq1.merge(&pq3);
cout << "After merge 1 and 3\n" << pq1.toString(PRINTSIZE) << endl;
pq1.merge(&pq5);
cout << "After merge 1 and 5\n" << pq1.toString(PRINTSIZE) << endl;
clock_t time = clock() - start;
cout << "Elapsed time = " << ((float)time) / CLOCKS_PER_SEC << endl;
fout << "Elapsed time = " << ((float)time) / CLOCKS_PER_SEC << endl;
fout.close();
}