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

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.

主站蜘蛛池模板: 双峰县| 丰顺县| 虞城县| 平陆县| 龙江县| 满城县| 民乐县| 基隆市| 江安县| 花垣县| 武川县| 梨树县| 温宿县| 伊川县| 海伦市| 南投县| 岑溪市| 怀仁县| 马山县| 永康市| 丰台区| 利川市| 凤城市| 项城市| 都江堰市| 龙里县| 繁昌县| 林周县| 濉溪县| 方城县| 惠水县| 台北市| 油尖旺区| 嘉善县| 贡嘎县| 手机| 滨海县| 望江县| 繁峙县| 水富县| 七台河市|