#pragma once

#include <stdlib.h>

template <typename T>
class ListRange;

template <typename T>
class ListIterator;

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

template<typename T>
class List {
public:
	List() = default;
	virtual ~List();
	List(const List &) = delete;
	List(List &&) = delete;
	List & operator = (const List &) = delete;
	List & operator = (List &&) = delete;

public:
	size_t size() const;

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

	void pop_back();

	void clear();

	T & operator [] (size_t index) const;

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

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

#include "List.hpp"