Design: Iterator Pattern Implementation
Design the iterator pattern focusing on the interface and interaction with collections. Implementation details of collections themselves are out of scope except for demonstration.
Functional Requirements
FR1: Provide a way to access elements of a collection sequentially without exposing its underlying representation
FR2: Support multiple types of collections (e.g., lists, trees, graphs)
FR3: Allow multiple iterators to traverse the same collection independently
FR4: Support forward traversal at minimum; optional support for backward traversal
FR5: Ensure the iterator interface is simple and consistent across collection types
Non-Functional Requirements
NFR1: Iterator operations should have O(1) time complexity where possible
NFR2: Memory overhead should be minimal and proportional to the number of active iterators
NFR3: The design should be extensible to support new collection types without modifying existing code
NFR4: Thread safety is not required in the initial design
