Posts

Showing posts from July, 2021

Iterator Pattern

Basically It belong to the group of behavioural pattern. Iterator pattern is used to iterate over collection in sequential order. The implementation shown below is modified version of Iterator pattern. In the below implementation, you will have options to go to next or choose previous Item. Following classes will be seen in the Implementation. 1 - Interface Iterator 2 - Concrete Iterator 3 - Interface Collection 4 - Concrete Collection ----------------------------------------------------------------------------------------- 1 - Interface Iterator Class: using System.Collections.Generic; namespace IteratorPatternVersion1.Interface {  public interface IIterator<T> {        List<T> CollectionList { get; set; }       T First { get; }       T Next { get; }       T Previous { get; }       T CurrentItem { get; }       bool IsDone { get; }       void Incremen...