-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinked_list.h
More file actions
49 lines (43 loc) · 1.16 KB
/
linked_list.h
File metadata and controls
49 lines (43 loc) · 1.16 KB
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
41
42
43
44
45
46
47
48
49
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
namespace linked_list{
template<class T>
struct Node{
T data;
struct Node *next;
};
}
template<class T>
class LinkedList{
private:
struct linked_list::Node<T> *first;
struct linked_list::Node<T> *tail;
int length;
public:
// Constructors
LinkedList();
LinkedList(int n, const T arr[]);
// Accessors (Getter Functions)
int size() const;
T at(int index) const;
// Mutators (Setter Functions)
void insert(int index, T data);
T remove(int index);
void prepend(T data);
void append(T data);
T pop_front();
T pop_back();
// Facilitators
void display() const;
void reverse();
void concat(LinkedList& ll);
// Enquiry Functions
bool isEmpty() const;
// Operator Overloads
T& operator[](int index) const;
template <class U>
friend std::ostream &operator<<(std::ostream &cout, const LinkedList<U> &ll);
// Destructor
~LinkedList();
};
#endif