This preview shows page 1. Sign up to view the full content.
Unformatted text preview: erator()
current = head;
} serves that purpose.
W e probably should set current to 0 iin the
current to n
constructor to indicate a non-set iterator, as it will
set iterator as
be when the end is reached.
be Applied Programming How about Applied Programming The next function returns the data at the current
node of the list and moves current on to the next
int tmp = current->data;
current = current->next;
} It will fail if current iis 0, so there should be a
current s so
Applied Programming Here is how an iterator is used:
iterator bool LinkedList::More()
return (current != 0);
} LinkedList list;
// There is a problem.
W hat if the user adds or deletes a node while
Such changes should be locked out.
Or current should be reset to ?.
Or current should //
Applied Programming set up the list
data = list.Next();
Applied Programming W e can actually use iterators to perform
additions and deletions.
void InsertBeforeCurrent(const int&);
int DeleteCurrent(); W e would need the extra member data variable
previous for these extra actions.
Iteration could then continue. Recall:
const int MAXTITLE = 40;
const int MAXCATEGORY = 10;
LinkedList VideoDB; Applied Programming Applied Programming W hy can't Video be a class?
Video We now provide
int ListDataCmp(const Video& V1,
const Video& V2);
to indicate the alphabetical order of the Title.
Everything else is as described in our general
In fact we can go one step further.
Applied Programming A further possibility. W e cou...
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14
- Computer Science