📄 c04p193.txt
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -