1 / 13

Unit 16 Iterator

Unit 16 Iterator. Summary prepared by Kirk Scott. Design Patterns in Java Chapter 28 Iterator. Summary prepared by Kirk Scott. The Introduction Before the Introduction. This chapter is divided into 3 parts: 1. Ordinary Iteration 2. Thread-Safe Iteration 3. Iterating over a Composite

fadey
Download Presentation

Unit 16 Iterator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit 16Iterator Summary prepared by Kirk Scott

  2. Design Patterns in JavaChapter 28Iterator Summary prepared by Kirk Scott

  3. The Introduction Before the Introduction • This chapter is divided into 3 parts: • 1. Ordinary Iteration • 2. Thread-Safe Iteration • 3. Iterating over a Composite • I am going to dispense with each part in about 1 overhead

  4. Ordinary Iteration • This refers to the Iterator class with three methods: hasNext(), next(), and remove() • The Iterable interface, which means a domain class has an iterator() method that returns an iterator on an instance of that class • For each loops, which allow you to traverse the contents of a collection with an iterator • This is all standard stuff, and it’s assumed that you are at least generally familiar with it

  5. Thread-Safe Iteration • This is beyond the scope of this course • No doubt it is a fascinating topic, full of tricks and traps, but if you don’t know what threads are, it’s pointless to talk about iteration in that context

  6. Iterating over a Composite • This is the part of the chapter where the book develops some code, making the classes of the Composite design pattern implement the Iterable interface • This means also developing a hierarchy of Iterator classes for components, leaves, and composites • This is relatively complex

  7. As an introduction to iteration as a design pattern it would be better to implement iterability over a simpler programmer developed collection class • For example, the general idea of a stack came up in the discussion of the Memento design pattern, so that data structure should be familiar • Keep this in mind as an assignment or test question problem

  8. The End

  9. All of the book diagrams for the chapter are tipped in on the following overheads for future reference • They are not needed in this iteration of the overheads and you’re not responsible for what they contain

More Related