-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIterator.cs
More file actions
22 lines (20 loc) · 921 Bytes
/
Iterator.cs
File metadata and controls
22 lines (20 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace DesignPatterns.Behavioral.Iterator;
/// <summary>
/// Iterator Pattern
///
/// Intent: Provide a way to access the elements of an aggregate object sequentially
/// without exposing its underlying representation.
///
/// When to use:
/// - When you want to access an aggregate object's contents without exposing its internal structure
/// - When you want to support multiple traversals of aggregate objects
/// - When you want to provide a uniform interface for traversing different aggregate structures
///
/// Real-world analogy: A TV remote's "next channel" button — you cycle through
/// channels one at a time without knowing how they're stored internally.
/// </summary>
// TODO: Implement Iterator
// 1. Iterator interface with MoveNext(), Current(), Reset()
// 2. Aggregate interface with CreateIterator()
// 3. Concrete aggregate (collection)
// 4. Concrete iterator traversing the collection