dyngoman
24th March 2010, 08:56
How can one create a circular linked list?One witch iterator jumps from end to begin automatically .
i.e.
QLinkedList<QObject> list;
QLinkedList<QObject>::iterator indexer;
//...
list.begin().i->p = list.end().i->n;
list.begin().i->p->t = list.end().i->t;
list.end().i->n->t = list.begin().i->t;
indexer= list.begin();
indexer++;
When indexer reaches list.end I want indexer++ to jump automatically at list.begin.
For some reason program crashes at line 5.
Is there a better solution to this problem?
i.e.
QLinkedList<QObject> list;
QLinkedList<QObject>::iterator indexer;
//...
list.begin().i->p = list.end().i->n;
list.begin().i->p->t = list.end().i->t;
list.end().i->n->t = list.begin().i->t;
indexer= list.begin();
indexer++;
When indexer reaches list.end I want indexer++ to jump automatically at list.begin.
For some reason program crashes at line 5.
Is there a better solution to this problem?