本文整理汇总了C++中SList::removeAll方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::removeAll方法的具体用法?C++ SList::removeAll怎么用?C++ SList::removeAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::removeAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unittest
/*
* Unit testing functions. Do not alter.
*/
void unittest ()
{
cout << "\nSTARTING UNIT TEST\n\n";
SList<int> intList;
cout << "INTEGER LIST TEST\n\n";
try {
btassert<bool>(intList.getSize() == 0);
cout << "Passed TEST 1: default constructor (size) \n";
} catch (bool b) {
cout << "# FAILED TEST 1: default constructor (size) #\n";
}
try {
btassert<bool>(intList.toString() == "");
cout << "Passed TEST 2: toString \n";
} catch (bool b) {
cout << "# FAILED TEST 2: toString #\n";
}
intList.insert(10);
try {
btassert<bool>(intList.getSize() == 1 && intList.toString() == "10");
cout << "Passed TEST 3: insert(10)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 3: insert(10)/getSize/toString #\n";
}
intList.insert(10);
try {
btassert<bool>(intList.getSize() == 2 && intList.toString() == "10,10");
cout << "Passed TEST 4: insert(10)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 4: insert(10)/getSize/toString #\n";
}
intList.insert(30);
try {
btassert<bool>(intList.getSize() == 3 && intList.toString() == "10,10,30");
cout << "Passed TEST 5: insert(30)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 5: insert(30)/getSize/toString #\n";
}
intList.insert(30);
try {
btassert<bool>(intList.getSize() == 4 && intList.toString() == "10,10,30,30");
cout << "Passed TEST 6: insert(30)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 6: insert(30)/getSize/toString #\n";
}
intList.insert(15);
try {
btassert<bool>(intList.getSize() == 5 && intList.toString() == "10,10,15,30,30");
cout << "Passed TEST 7: insert(15)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 7: insert(15)/getSize/toString #\n";
}
intList.insertHead(5);
try {
btassert<bool>(intList.getSize() == 6 && intList.toString() == "5,10,10,15,30,30");
cout << "Passed TEST 8: insertHead(5)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 8: insertHead(5)/getSize/toString #\n";
}
intList.insertTail(50);
try {
btassert<bool>(intList.getSize() == 7 && intList.toString() == "5,10,10,15,30,30,50");
cout << "Passed TEST 9: insertTail(50)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 9: insertTail(50)/getSize/toString #\n";
}
try {
btassert<bool>(intList.removeFirst(1) == false);
cout << "Passed TEST 10: removeFirst(1) \n";
} catch (bool b) {
cout << "# FAILED TEST 10: removeFirst(1) #\n";
}
try {
btassert<bool>(intList.removeAll(100) == false);
cout << "Passed TEST 11: removeAll(1) \n";
} catch (bool b) {
cout << "# FAILED TEST 11: removeAll(1) #\n";
}
try {
btassert<bool>(intList.removeFirst(10) == true && intList.getSize() == 6 && intList.toString() == "5,10,15,30,30,50");
cout << "Passed TEST 12: removeFirst(10)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 12: removeFirst(10)/getSize/toString #\n";
//.........这里部分代码省略.........