📄 sortedlistisa.cpp
字号:
#include "SortedListIsA.h"SortedList::SortedList(){} // end default constructorSortedList::SortedList(const SortedList& sList): List(sList){} // end copy constructorSortedList::~SortedList(){} // end destructorvoid SortedList::sortedInsert(ListItemType newItem) throw(ListException){ bool found; int newPosition = locatePosition(newItem, found); insert(newPosition, newItem);} // end sortedInsertvoid SortedList::sortedRemove(ListItemType anItem) throw(ListException){ bool found; int position = locatePosition(anItem, found); if (found) // item actually found remove(position); else throw ListException("ListException: Item to remove not found");} // end sortedRemoveint SortedList::locatePosition(ListItemType anItem, bool& isPresent){ ListNode *trav = getHead(); int position = 1; while ((trav != NULL) && (getNodeItem(trav) < anItem)) { trav = getNextNode(trav); position++; } // end while if ((trav != NULL) && (anItem == getNodeItem(trav))) isPresent = true; else isPresent = false; return position;} // end locatePosition
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -