Download presentation
Presentation is loading. Please wait.
1
Feb 200692.3913 Ron McFadyen1 Iterator Pattern Generic UML class diagram The iterator is used to access the elements of some aggregate. The aggregate interface gives us a common way to create an iterator. The iterator interface gives us a common way to access components of the aggregate > Aggregate createIterator() next() hasNext() remove() ConcreteAggregate Client ConcreteIterator() > Iterator next() hasNext() remove() createIterator()
2
Feb 200692.3913 Ron McFadyen2 Text Example UML class diagram Each menu class has responsibility to create the necessary iterator. Note that the iterator pattern is an example of a Factory (i.e. objects are created). > Menu createIterator() next() hasNext() remove() PancakeHouseMenu Waitress DinerMenuIterator() > Iterator next() hasNext() remove() createIterator() DinerMenu createIterator() PancakeHouseIterator() next() hasNext() remove()
3
Feb 200692.3913 Ron McFadyen3 Sample Behaviour :DinerMenu :Waitress :DinerMenuIterator createIterator() new() hasNext() next() Loop [hasNext true] hasNext()
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.