c04p193.txt

来自「Data Abstraction & Problem Solving with 」· 文本 代码 · 共 32 行

TXT
32
字号
bool List::isEmpty() const{   return size == 0;}  // end isEmptyint List::getLength() const{   return size;}  // end getLengthList::ListNode *List::find(int index) const// --------------------------------------------------// Locates a specified node in a linked list.// Precondition: index is the number of the// desired node.// Postcondition: Returns a pointer to the desired// node. If index < 1 or index > the number of// nodes in the list, returns NULL.// --------------------------------------------------{   if ( (index < 1) || (index > getLength()) )      return NULL;   else  // count from the beginning of the list   {  ListNode *cur = head;      for (int skip = 1; skip < index; ++skip)         cur = cur->next;      return cur;   }  // end if}  // end find

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?