Is there a circular relationship between a collection and its iterator?

An iterator definitely needs to know about the collection that it needs to iterate. Should I also collect information about its iterator? Is addiction one or two ways? If a collection has knowledge of a particular iterator implementation, then it may not be possible to have different iterator strategies for the same collection. That is my thought. Am I right, or did I understand that this is completely wrong?

The GoF book has this diagram for the Iterator template:

enter image description here

I think this implies circular dependence. I am not sure about the dashed lines from Listbefore LisIteratorand SkipListto SkipListIterator.

PS: I do Java every day, but maybe this is more a design issue than a specific language.

+5
2

, , .

. 4- , . 15, 1.6.

, CreateIterator Java iterator().

Geek Humor: , - "INSTANTATION"

+2

, . , .

, , ArrayList , , , .

+1

All Articles