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

Explaining Iterator

Imagine that we want a way to access elements of an aggregate object sequentially without exposing its internal structure. The Iterator pattern does just that.

The Iterator pattern is responsible for sequentially accessing the aggregate object and defining an interface to access the elements without exposing the internal structure. This interface doesn't put a new element on the aggregate object, but simply reads elements to it. In the following diagram, you can see the structure of an Iterator and how it is designed:

In the preceding diagram, we can see the Aggregate and Iterator interfaces with their concrete subclasses. The client is the class that uses the Iterator to access elements of Aggregate.

This pattern is used on Java collections such as list, deque, and set. Understanding this pattern will help you to understand Java collections.

主站蜘蛛池模板: 迭部县| 万盛区| 富宁县| 彩票| 保亭| 西和县| 镇坪县| 鹤庆县| 花莲县| 库尔勒市| 乐平市| 禄丰县| 济源市| 濉溪县| 汽车| 益阳市| 原阳县| 治县。| 苗栗县| 阿坝县| 金坛市| 鲜城| 永顺县| 泾川县| 休宁县| 宜春市| 台北市| 邮箱| 博乐市| 桦川县| 甘南县| 济阳县| 文安县| 康平县| 台中市| 博乐市| 蓝田县| 兴义市| 南华县| 漳平市| 天镇县|