本文整理汇总了C++中SortedList::Delete方法的典型用法代码示例。如果您正苦于以下问题:C++ SortedList::Delete方法的具体用法?C++ SortedList::Delete怎么用?C++ SortedList::Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedList
的用法示例。
在下文中一共展示了SortedList::Delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
SortedList<int> list;
int mainItem;
list.Insert(352);
list.Insert(48);
list.Insert(12);
list.Insert(40);
list.Print();
if (!list.IsEmpty())
{
list.DeleteTop(mainItem); // delete the first node
cout << "node delete was " << mainItem << endl << endl;
}
cout << "\nprint out list after delete" << endl;
list.Print();
list.Insert(1); // insert at the top of the list
list.Insert(500); //insert at the bottom of the list
list.Insert(77); // insert in the middle
cout << "\nprint the list after inserting nodes"<< endl;
list.Print();
list.Delete(48); // delete in the middle
cout << "\nprint the list deleting a middle node"<< endl;
list.Print();
list.Delete(1); // delete the first node
cout << "\nprint the list deleting the first node" << endl;
list.Print();
list.Delete(500); // delete the last node
cout << "\nprint the list deleting the last node" << endl;
list.Print();
while(!list.IsEmpty())
{
list.DeleteTop(mainItem);
}
cout << "List is empty: " << (list.IsEmpty()? "true\n": "false\n");
list.DeleteTop(mainItem);
list.Delete(2);
}