Skip to main content
GameDev.net gamedev.net
🔒 Locked

Linked List

Started by dave Dec 24, 2004 at 4:23 PM 3 replies 1k views
Original Post
dave
dave
For educational purposes im writing my own linked lilst class. Basically if you guys could please list what u think it should be able to do, that would be great. ace
JimPrice
JimPrice
Why not have a look at what the STL list offers, as this is typically implemented as a linked list.

Jim.
Mayrel
Mayrel
Something like
template<typename T>class Node{public:  Node (T head, Node* tail = 0);  T      head() const;  Node*  tail() const;  T&     head();  Node*& tail();};template<typename T>class List{public:  List (T item1, T item2, T item3, T item4, T item5, T item6);  List (T item1, T item2, T item3, T item4, T item5);  List (T item1, T item2, T item3, T item4);  List (T item1, T item2, T item3);  List (T item1, T item2);  List (T item1);  List ();  const Node* head () const;  Node*& head ();  T& operator[] (int index); // Only in the class because it must be.};
JesseT
JesseT
template <typename T> class List{public:    List();    List(List const& other);    List& operator=(List const& other);    ~List();    List(std::size_t size);        void PushFront(T const& value);    void PopFront();     ...    Doom4* MakeDoom4();private:    struct Node    {        Node* prev;        Node* next;        T data;    }    Node root;};
doynax
doynax
You'll have to decide for yourself what you think you're capable of, however I can give some examples of some interesting features you could implement.
Here's a few things that'll separate you from STL (i.e. give people a reason to use the list): Xor-Linking, sentinel nodes, selectable link members though member data pointers, opaque data types in pure C.
I'll leave the googling to you..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.