#1 Added count method to Linked List

This commit is contained in:
Luke Else 2022-11-22 21:28:04 +00:00
parent 15c4684857
commit ee0556730d
2 changed files with 8 additions and 0 deletions

View File

@ -101,6 +101,11 @@ namespace Datastructures {
return true;
}
template <typename T>
int LinkedList<T>::count() const {
return this->mCount;
}
template <typename T>
int LinkedList<T>::find(const T& value) const {
//Start at the head of the list

View File

@ -1,3 +1,4 @@
#include <iostream>
#include <linkedlist.h>
int main() {
@ -5,6 +6,8 @@ int main() {
list.append(5);
list.append(200);
list.insert(20, 2);
std::cout << list.count() << std::endl; //3
list.remove(0);
int x = list.find(10);
std::cout << list.count() << std::endl; //2
}