vector<Type> SinglyLinkedList<Type>::convertToVector() { vector<Type> v; if (size == 0) return v; LinkedListNode<Type>* pLoc = head; while (pLoc->next != nullptr) { Efficiency::totalDataStructureOperations++; v.push_back(pLoc->getData()); pLoc = pLoc->next; } Efficiency::totalDataStructureOperations++; v.push_back(pLoc->getData()); return v; }
Type SinglyLinkedList<Type>::get(int key) { LinkedListNode<Type>* pLoc = head; while (pLoc != nullptr) { if (pLoc->getKey() == key) { Efficiency::totalDataStructureOperations++; return pLoc->getData(); } Efficiency::totalDataStructureOperations++; pLoc = pLoc->next; } throw "not found"; }