Iterators for a quadruply linked list

Hello so I am working on implementing a list which would fall under the category of a quadruply linked list. I class defining the nodes, iterators and list:
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
template <class T>
class node {
public:
    node<T>* next;
    node<T>* prev;
    node<T>* top;
    node<T>* down;
};

template <class T>
class iter {
   ...
   iter<T>& operator++(){
        ptr = ptr->next;
    }
    ...
private:
    node<T>* ptr;
}

template <class T>
class mylist {
    ...
    typedef iter<T> iterator;
    iterator begin_sideways() { return iterator(head_sideways); }

private:
    node<T>* head_sideways;
    node<T>* tail_sideways;
    node<T>* head_up;
    node<T>* head_down;
};


So if I want to walk along the list in one direction I can simply define and iterator and set it equal to the beginning of the list. My question is this, how can I 'overload' my iterator definition so I can use the same instance of an iterator already defined in order to walk along the list in the other direction?
Last edited on
You don't have a list; there is no such thing as a quadruply linked list. Instead, you have a graph. It doesn't make sense to define iterators for a graph.
Just play along with me and let's say it is a list.
No.

It might make sense to want to iterate over every node in a graph, but I don't know a good way to do that.
Last edited on
Topic archived. No new replies allowed.