#1 Added count method to Linked List
This commit is contained in:
parent
15c4684857
commit
ee0556730d
@ -101,6 +101,11 @@ namespace Datastructures {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
int LinkedList<T>::count() const {
|
||||||
|
return this->mCount;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
int LinkedList<T>::find(const T& value) const {
|
int LinkedList<T>::find(const T& value) const {
|
||||||
//Start at the head of the list
|
//Start at the head of the list
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <iostream>
|
||||||
#include <linkedlist.h>
|
#include <linkedlist.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@ -5,6 +6,8 @@ int main() {
|
|||||||
list.append(5);
|
list.append(5);
|
||||||
list.append(200);
|
list.append(200);
|
||||||
list.insert(20, 2);
|
list.insert(20, 2);
|
||||||
|
std::cout << list.count() << std::endl; //3
|
||||||
list.remove(0);
|
list.remove(0);
|
||||||
int x = list.find(10);
|
int x = list.find(10);
|
||||||
|
std::cout << list.count() << std::endl; //2
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user