GoF Definition: Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
Iterators are generally used to traverse a container to access its elements.
Suppose there are two companies: Company A and Company B. Company A stores its employee records (name, etc.) in a linked list and Company B stores its employee data in a big array. One day the two companies decide to work together. The iterator pattern is handy in such a situation. We need not write codes from scratch. We’ll have a common interface through which we can access data ...