what do the java collection framework iterators provide ...se362/patternoverviews/iterator.pdf · 1...

1
1 1 What do the Java Collection Framework iterators provide for you? 2 The Iterator pattern provides controlled access to a collection without exposing internals. §Given An aggregate collection of objects §Desired Access all elements in the collection Do not expose internal structure Access is independent of the collection Multiple accesses can be done independent of each other Collection can be maintained independent of the access §Solution Iterator object controls access

Upload: others

Post on 24-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: What do the Java Collection Framework iterators provide ...se362/PatternOverviews/Iterator.pdf · 1 1 What do the Java Collection Framework iterators provide for you? 2 The Iterator

1

1

What do the Java Collection Framework iterators provide for you?

2

The Iterator pattern provides controlled access to a collection without exposing internals.

§Given• An aggregate collection of objects

§Desired• Access all elements in the collection• Do not expose internal structure• Access is independent of the collection• Multiple accesses can be done independent of

each other• Collection can be maintained independent of the

access

§Solution• Iterator object controls access