for (int vtotal +iimplementing iterators one way to implement an iterator for collection of elements is to make "snapshotof it and iterate over that this approach would involve storing the collection in separate data structure that supports sequential access to its elements for examplewe could insert all the elements of the collection into queuein which case method hasnext(would correspond to !isempty(and next(would correspond to enqueue(with this approachthe method iterator(takes (ntime for collection of size since this copying overhead is relatively costlywe preferin most casesto have iterators operate on the collection itselfnot copy in implementing this direct approachwe need only to keep track of where in the collection the iterator' cursor points thuscreating new iterator in this case simply involves creating an iterator object that represents cursor placed just before the first element of the collection likewiseperforming the next(method involves returning the next elementif it existsand moving the cursor just past this element' position thusin this approachcreating an iterator takes ( timeas do each of the iterator' methods we show class implementing such an iterator in code fragment and we show in code fragment how this iterator could be used to implement the iterator(method in the nodepositionlist class code fragment position list an element iterator class for