官术网_书友最值得收藏!

Using the iterator pattern

The purpose of the iterator design pattern is to grant access to an object's members without sharing the encapsulated data structures. There are two main motivations for using the iterator design pattern. First, not all object data is stored in the same manner. For example, an online store that aggregates content from other vendors might have a vendor that uses an array, another that uses a list, and a third that uses an ArrayList. A second reason is to avoid exposing data structures. Both the variability of storage approaches and data security can be addressed with the iterator design pattern.

The iterator design pattern is implemented by using the Iterator interface, part of the java.util package.

We will look at a simple use case, the UML class diagram, and the source code necessary to implement the iterator design pattern for this scenario.

主站蜘蛛池模板: 宜宾市| 三亚市| 龙游县| 伊春市| 嘉义县| 个旧市| 安庆市| 湟中县| 临湘市| 克什克腾旗| 迭部县| 旅游| 沁源县| 衡山县| 尖扎县| 博乐市| 瑞金市| 鄢陵县| 南雄市| 绥宁县| 龙海市| 华蓥市| 新宁县| 确山县| 井研县| 简阳市| 全州县| 甘孜县| 益阳市| 雅安市| 荔浦县| 远安县| 仙桃市| 江都市| 农安县| 策勒县| 平罗县| 岑巩县| 建阳市| 民乐县| 南宁市|