Get the App
SLTechnology News&Howtos  ›  Network Security  › 

TryBestToCode Iterator (iterator)-object behavior pattern

Shulou Source: shulou.com Published: 2022-06-01 05:53:15 09月14日 Update

1. intention

Provides a way to sequentially access elements in an aggregate object without exposing the object's internal representation.

2. alias

Cursor-Cursor.

3. motivation

An aggregate object should provide a way for others to access its elements without exposing its internal structure.

4. applicability

Access the contents of an aggregate object without exposing its internal representation.

Support multiple traversals of aggregated objects.

Provides a uniform interface for traversing different aggregation structures, i.e., supports polymorphic iterations.

5. structure

6. effect

The iterator pattern has three important functions:

Support for traversing an aggregation in different ways, complex aggregations can be traversed in multiple ways.

Iterators simplify the aggregation interface, and with iterator traversal interfaces, aggregation itself no longer requires similar traversal interfaces.

There can be multiple iterations on the same aggregate, and each iterator keeps its own traversal state, so you can do multiple iterations at the same time.

Tags: Object iteration interface structure support different element multiple multiple way method pattern complex polymorphic important three function content alias motivation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Docker Shulou Information MySQL