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

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.

主站蜘蛛池模板: 黄石市| 泾川县| 闵行区| 上思县| 定远县| 同仁县| 松溪县| 谷城县| 略阳县| 大田县| 茂名市| 西宁市| 寿阳县| 乌拉特前旗| 凤冈县| 出国| 克东县| 肥东县| 凤阳县| 台州市| 宜丰县| 本溪市| 伊川县| 商河县| 盖州市| 丰原市| 洛宁县| 澎湖县| 福贡县| 佛坪县| 浪卡子县| 佛坪县| 拉孜县| 重庆市| 乐业县| 阜城县| 富源县| 丰镇市| 儋州市| 绵竹市| 昭平县|