-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingle_Linked_List.h
More file actions
46 lines (36 loc) · 902 Bytes
/
Copy pathSingle_Linked_List.h
File metadata and controls
46 lines (36 loc) · 902 Bytes
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
#pragma once
#include <iostream>
#include <fstream>
#include <array>
#include <string>
#include <cmath>
#include <stdexcept>
#include <cstddef>
using namespace std;
//Maybe could use this list to store names eventually but for now integers only
template <typename T>
class Single_Linked_List {
private:
struct Node {
T data;
Node* next;
Node(T d) : data(d), next(nullptr) {}
};
Node* head;
Node* tail;
size_t num_items;
public:
Single_Linked_List() : head(nullptr), tail(nullptr), num_items(0) {}
~Single_Linked_List();
size_t size() const;
void push_front(const T& item);
void push_back(const T& item);
void pop_front();
void pop_back();
T& front();
T& back();
bool empty() const;
void insert(size_t index, const T& item);
bool remove(size_t index);
size_t find(const T& item) const;
};