Hi,
I am not a well - versed programmer, but yes, you do have a linked list going there in one direction. How about trying a dual linked list (a list that has pointers going in both directions so that if you had
A B C
and the "now" is on B, that you have the pointer information for both A and C, so that you can move forwards or backwards.
Then, for queue mode, go to the end of the list, and work it backwards using the reverse pointers.
Christian
kc0arf
Posting Virtuoso
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
your add_item method should traverse to the END of the list, and add the element there. the remove_item method should remove the first element in the list.
infamous
Junior Poster in Training
77 posts since Mar 2004
Reputation Points: 47
Solved Threads: 2
Hi,
I think infamous is right! Might have mis-read what you are trying to do.
I do know that in my programming days, I did make a lot of linked lists both ways, just for flexibility. I also kept another copy of the head pointer around in another variable in the event I "lost" it during coding.
Christian
kc0arf
Posting Virtuoso
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57