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

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.

主站蜘蛛池模板: 西平县| 阿拉善左旗| 峨边| 喀喇沁旗| 永靖县| 西宁市| 栖霞市| 嘉荫县| 昌宁县| 新泰市| 彩票| 鄄城县| 宁南县| 库伦旗| 琼结县| 沾益县| 洮南市| 崇仁县| 陇川县| 成安县| 苏尼特左旗| 内江市| 尚志市| 沙坪坝区| 察哈| 天祝| 怀柔区| 扎兰屯市| 鄂伦春自治旗| 伊川县| 正定县| 合阳县| 鹿邑县| 凌海市| 磐安县| 上高县| 黑河市| 建水县| 九龙县| 固阳县| 丹凤县|