提供一种方法顺序访问一个聚合对象中的各个元素,而又不暴露该对象的内部表示。
迭代器模式分离了集合对象的遍历行为,它抽象出一个迭代器类来负责具体的遍历行为,这样做的好处就是既不暴露集合内部的结构,又可以让外部代码以透明的方式访问集合内部的数据。
迭代器模式适用于以下几种情况:
- 当需要访问一个聚集对象的内容而又不想暴露它的内部表示时;
- 当希望支持对聚集对象的多种遍历方式时;
- 当需要为遍历不同的聚集结构提供统一的对外接口时;
GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Unity3DTraining/DesignPatterns/IteratorPattern at master · UnitySample/Unity3DTraining |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |