#ifndef __LinkedLIST_INCLUDE_H_ #define __LinkedLIST_INCLUDE_H_ #include "user/lib/List.h" #include template class Wrapper { public: Wrapper(T value) : value(value) {} T value; Wrapper* next; Wrapper* prev; // Allow implicit conversion to make the ListIterator dereferencing work operator T() { return value; } }; // Implement linked traversal by extending the ListIterator template class LinkedListIterator : public ListIterator { public: LinkedListIterator& operator++() override { // ptr is of type Wrapper* this->ptr = this->ptr->next; return *this; } }; template class LinkedList : public List, LinkedListIterator>> { public: using Type = typename List, LinkedListIterator>>::Type; // T is different from the List type (Wrapper) // so take the type out of the base class using Iterator = typename List, LinkedListIterator>>::Iterator; private: Type* head; Type* tail; protected: Type* begin_ptr() override { return this->head; } Type* end_ptr() override { return this->tail->next; } public: LinkedList() : head(NULL), tail(NULL) {} unsigned int insert(Type e) override {} unsigned int insert_at(Type e, unsigned int i) override {} Type remove_at(unsigned int i) override {} Type remove_first() override {} Type remove_last() override {} bool remove(Type e) override {} Type get(unsigned int i) const override {} Type first() const override {} Type last() const override {} bool empty() const override {} unsigned int size() const override {} void print(OutStream& out) const override {} }; #endif