⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sortedlistisa.cpp

📁 Data Abstraction & Problem Solving with C++源码
💻 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 + -