Design Pattern: Iterator (Behavioural)

A MATLAB® OOP implementation of the Iterator Behavioural Design Pattern

이 제출물을 팔로우합니다

Intent: Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation [1]. This design pattern is also known as Cursor.
Motivation: An example of an aggregate object is an instance of the List ADT. Consequently, an iterator can be used to traverse the elements of a list with a set of high-level abstract operations. These operations may be implemented within the List ADT but as Gamma et al.[1] wonderfully puts it, the key idea in this pattern is to take the responsibility for access and traversal out of the list object and put it into an iterator object - given the iterator describes behaviour whilst the list describes a collection.

Implementation: The Iterator abstract class is used purely to specify the requirements of its concrete implementation. This abstraction could be implemented as an external/active or internal/passive iterator -
External := the onus is on the client to advance the traversal and request next elements.
Internal := the client can supply an operation to the iterator to perform over every element of a collection

Refer to pp.257-271 Gamma et al.[1] for more information on the Iterator (Behavioural) Design Pattern.

Written by Bobby Nedelkovski
MathWorks Australia
Copyright 2009-2010, The MathWorks, Inc.

Reference:
[1] Gamma, E., Helm, R., Johnson, R. and Vlissides, J. Design Patterns : Elements of Reusable Object-Oriented Software. Boston: Addison-Wesley, 1995.

인용 양식

Bobby Nedelkovski (2026). Design Pattern: Iterator (Behavioural) (https://kr.mathworks.com/matlabcentral/fileexchange/25225-design-pattern-iterator-behavioural), MATLAB Central File Exchange. 검색 날짜: .

도움

도움 받은 파일: Data Structure: A Cell Array List Container

카테고리

Help CenterMATLAB Answers에서 Software Development에 대해 자세히 알아보기

일반 정보

MATLAB 릴리스 호환 정보

  • 모든 릴리스와 호환

플랫폼 호환성

  • Windows
  • macOS
  • Linux
버전 퍼블리시됨 릴리스 정보 Action
1.5.0.1

Updated license

1.5.0.0

Allow creation of N-D arrays of CellArrayListIterators - this is due to the changes in CellArrayList (see File Exchange item #25024). UML Diagram has been updated to reflect the change.

1.3.0.0

Abstract properties in abstract classes List and Iterator changed to concrete protected - conforms with R2009b OOP. Updated UML diagram to reflect this change. Bug fix with remove() method in CellArrayList.

1.2.0.0

Removed details on the implementation from the 'Description' field as this can be found in 'CellArrayListIterator.m' and included references to the files of interest.

1.0.0.0