Learning Outcomes
At the end of this lecture, you’ll be able to:
- Describe the iterator design pattern.
- Differentiate between the Java
Iterable
andIterator
interfaces. - Declare, specify and test Iterable ADTs.
- Write a Java class that implements the
Iterable
interface. - Write a Java class that implements the
Iterator
interface. - Appreciate that an inner class (non-static) Iterator implementation is an instance member and has access to the instance members of the outer class.
- Understand the data encapsulation resulting from private inner classes.
Lecture Plan
In this lecture, we'll cover the following lessons:
- Java Interlude: Enhanced For Loop
- Iterator Design Pattern
- Iterator Pattern: Iterable Interface
- Iterator Pattern: Test
- Iterator Pattern: Iterator Interface
- Implement the Iterator Pattern: Part I
- Implement the Iterator Pattern: Part II
- Implement the Iterator Pattern: Part III
- Implement the Iterator Pattern: Exercise⚡
Lessons marked with ⚡ contain exercise/activity.