-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkedList.h
40 lines (27 loc) · 831 Bytes
/
LinkedList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
#include "Node.h"
template <typename T>
class LinkedList
{
public:
//Constructor.
LinkedList();
//Destructor.
~LinkedList();
//Removes the node containing the given value from the list.
bool erase(T value, Node<T>* current=nullptr, Node<T>* prev=nullptr);
//Adds to the end of the list.
void insert(T value, Node<T>* current=nullptr);
//Prints the full contents of this LinkedList in a readable format.
void print();
//Search for a given value in this LinkedList. If not found, returns null.
Node<T>* find(T value);
//Returns whether this LinkedList is empty.
bool isEmpty();
private:
Node<T>* m_front; //Pointer to the front of this LinkedList.
int m_size; //Size tracking integer, for convenience.
};
#include "LinkedList.hpp"
#endif