#ifndef LIST_HEADER
#define LIST_HEADER

template<class T> class List
{
private:
	struct Item
	{
		T value;
		Item *next;
	};
	
public:
	class Iterator
	{
	friend class List;
	private:
		Item *current;
		Iterator(Item *item) {this->current = item;}
	public:
		Iterator(const Iterator &iterator) {this->current = iterator.current;}
		
		bool operator == (const Iterator &iterator) const {return this->current == iterator.current;}
		bool operator != (const Iterator &iterator) const {return this->current != iterator.current;}
		Iterator& operator ++ () {current = current->next; return *this;}
		Iterator& operator ++ (int) {current = current->next; return *this;}
		T& operator * () const {return current->value;}
		T* operator -> () const {return &(current->value);}
	};
		
private:
	Item *first;
	Item *last;
	
public:
	List();
	~List();
	
	Iterator PushFront(T value)
	{	
		Item *item = new Item;
		item->value = value;
		item->next = first;
		first = item;
		if (!last) last = first;
		
		return first;
	}	
	Iterator PushBack(T value)
	{
		if (!last) return PushFront(value);
		
		Item *item = new Item;
		item->value = value;
		item->next = 0;
		last->next = item;
		last = item;
		
		return last;		
	}
	void DeleteFirst()
	{
		Item *tmp = first;
		first = first->next;
		if (!first) last = 0;
		delete tmp;
	}
	
	Iterator Begin() const {return Iterator(first);}
	Iterator End() const {return Iterator(0);}
	
	bool Empty() {return first == 0;}
};

template<class T> List<T>::List()
{
	this->first = 0;
	this->last = 0;
}

template<class T> List<T>::~List()
{
	/*TODO: Destryctor :)*/
}

#endif
