aboutsummaryrefslogtreecommitdiff
path: root/backend/List.h
blob: 1d8893ef360c7dbe86bcf649358cbded616516da (plain)
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
#pragma once

#include <stdlib.h>

template <typename T>
class ListRange;

template <typename T>
class ListIterator;

template <typename T>
struct ListLink {
	ListLink<T> * prev;
	ListLink<T> * next;
	T value;
};

template<typename T>
class List {
public:
	size_t size();

	void push_back(T & el);
	void remove(const T & val);

	void pop_back();

	void clear();

	T & operator [] (size_t index);

	ListIterator<T> begin();
	ListIterator<T> end();
	ListRange<T> range();

private:
	ListLink<T> * head = nullptr;
	ListLink<T> * tail = nullptr;
	size_t length = 0;
};

#include "List.hpp"