void NodeController :: tryNodes() { DataNode<int> numberNode; DataNode<string> wordNode; cout << "Before" << endl; cout << numberNode.getNodeData() << endl; cout <<"After" << endl; numberNode.setNodeData(231); cout << numberNode.getNodeData() << endl; }
void NodeController :: tryNodes() { DataNode<int> numberNode; DataNode<string> wordNode; numberNode.setNodeData(345); cout << numberNode.getNodeData() << endl; }
Type SummerList<Type> :: remove(int index) { assert (index >= 0 && index < size); Type removedValue; DataNode<Type> *indexPointer = front; DataNode<Type> *removedNode = nullptr; DataNode<Type> *next = nullptr; if (size == 1) { removedValue = front->getNodeData(); delete indexPointer; front = nullptr; end = nullptr; } else if(index == 0) { removedValue = front->getNodeData(); front = front->getNodePointer(); delete indexPointer; } else { for(int position = 0; position < index - 1; position ++) { indexPointer = indexPointer->getNodePointer(); } removedNode = indexPointer->getNodePointer(); next = removedNode->getNodePointer(); if(removedNode == end) { end = indexPointer; } indexPointer->setNodePointer(next); removedNode->setNodePointer(nullptr); removedValue = removedNode->getNodeData(); delete removedNode; } size--; return removedValue; }
bool SummerList<Type> :: contains(Type data) { bool isInList = false; DataNode<Type> *containsPointer = front; for(int index = 0; index < size; index ++) { if (data == containsPointer->getNodeData()) { isInList = true; } containsPointer = containsPointer->getNodePointer();//changes the pointer to point to the next node } return isInList; }