CMPT 115 Lecture Notes - Lecture 9: Abstract Data Type, Pseudocode, Iter
Document Summary
Notes written by michael horsch, mark eramian, ian mcquillan, lingling jin, and dmytro dyachuk. 1 iterators of containers: a list is one example of a container. Here"s a pseudo-code fragment: for every reftoelement el in reftolist alist. A iterator allows a loop to step through a container, one element at a time: the action performed on each element is the known as the visit operation. It can be anything: we have already seen examples of list iteration tasks: Searching for the target in deleteelement, insertafter. What is the visit operation in the each of the iterative tasks listed above: we would like a way to do customized iterators without adding a new operation to the container"s. Adt for each kind of visit operation we might want: for example, we don"t want to have list adt operations for addition, multiplication, average, maxi- mum, etc. 2 a iterator adt: a iterator adt will have the following operations: