本文整理汇总了C++中ListNode::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ ListNode::getValue方法的具体用法?C++ ListNode::getValue怎么用?C++ ListNode::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListNode
的用法示例。
在下文中一共展示了ListNode::getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeById
void removeById(HashedDictionary<string, Racer>* dict, BinarySearchTree<Racer>* tree, Stack<Racer> *actionList, Stack<char> *commandList)
{
ListNode<string, Racer>* nodePtr;
string searchString;
cout << "Please enter ID for deletion (8 chars) : ";
getline(cin, searchString);
if (searchString.length() > 8)
{
cout << "ID NUMBERS ARE 8 CHAR MAX!\n";
return;
}
else if(!isId(searchString))
{
cout << "THIS IS NOT A VALID ID NUMBER!\n";
return;
}
nodePtr = dict->getItem(searchString);
if (nodePtr)
{
cout << "RACER FOUND!\n";
display(nodePtr->getValue());
string userInput = " ";
cout << "ARE YOU SURE YOU WANT TO DELETE? (Y/n): ";
getline(cin, userInput);
if (userInput[0] == 'Y')
{
Racer toStack = nodePtr->getValue();
actionList->push(toStack);
commandList->push('-');
dict->remove(searchString);
tree->remove(nodePtr->getValue());
}
else
{
return;
}
}
else
{
cout << "NO RACER FOUND WITH THAT ID.\n";
}
}
示例2: while
ostream & operator<<(ostream & stream, const LinkedList & list )
{
ListNode* currNode = list.head;
while (currNode != NULL)
{
cout << currNode->getValue();
currNode = currNode->getNext();
}
return stream;
}
示例3: while
ostream& operator<<(ostream &stream, const LinkedList &l) {
stream << "[";
ListNode *i = l.head;
while(i != NULL) {
stream << i->getValue();
i = i->getNext();
if(i != NULL)
stream << ", ";
}
stream << "]";
}
示例4: undo
void undo(Stack<Racer> *actionList, Stack<char> *commandList, HashedDictionary<string, Racer>* dict, BinarySearchTree<Racer>* tree)
{
char command;
Racer undoMe;
if (commandList->getCount() != actionList->getCount() || commandList->isEmpty() || actionList->isEmpty())
{
cout << "No previous commands\n";
return;
}
commandList->pop(command);
actionList->pop(undoMe);
string ID = *(undoMe.getIdNum());
if (command == '+')
{
//string ID = *(undoMe.getIdNum());
//remove from hashLL
//dict->remove(ID);
//remove from tree
ListNode<string, Racer>* nodePtr;
string searchString = ID;
nodePtr = dict->getItem(searchString);
if (nodePtr)
{
dict->remove(searchString);
tree->remove(nodePtr->getValue());
cout << "INSERT RETRACTED\n";
}
}
if (command == '-')
{
dict->add(ID, undoMe);
tree->insert(undoMe);
cout << "DELETION RETRACTED\n\n";
cout << "RESTORED DRIVER -> ";
display(dict->getItem(ID)->getValue());
cout << endl;
}
}
示例5: searchById
void searchById(HashedDictionary<string, Racer>* dict)
{
ListNode<string, Racer>* nodePtr;
string searchString;
cout << "Please enter the ID number that you are searching for(8 char max).\n";
getline(cin, searchString);
if(searchString.length() > 8)
{
cout << "ID NUMBERS ARE 8 CHAR MAX!\n";
return;
}
nodePtr = dict->getItem(searchString);
if(nodePtr)
{
cout << "RACER FOUND!\n";
display(nodePtr->getValue());
}
else
cout << "NO RACER FOUND WITH THAT ID.\n";
}
示例6: remove
void LinkedList::remove(const string &value)
{
ListNode* currNode = head;
ListNode* prevNode;
if (head == NULL) return;
while (currNode != NULL)
{
if (currNode->getValue() == value)
{
if (prevNode != NULL)
prevNode->next = currNode->getNext();
else
head = currNode->getNext();
delete currNode;
}
prevNode = currNode;
currNode = currNode->getNext();
}
last = currNode;
}