Talk:Computer Science Design Patterns/Visitor

Iteration or any traversal of a collection is not part of the Visitor Pattern
This is a common misunderstanding of the Visitor Pattern. This pattern is only concerned with double-dispatch in computer languages which only provide a single-dispatch mechanism. It is possible to use this pattern to make single requests to elements of a collection, similar to direct or random file access. It is also possible to use the visitor pattern to drive the traversal of elements in a collection to obtain different ordering, filtering, maintaining state etc.

This pattern is especially useful when combined with the Composite pattern to define a hierarchical structure containing many instances of different elements from an object hierarchy, and to process those elements by traversing either a sub-branch or the complete tree structure. note: two types of hierarchies But, this is a particular specialization of the pattern, not simply the pattern itself.
 * a structure, a collection of instances of objects
 * object hierarchy, the definitions of unique, related classes with a common parent

I will let this information digest a while before embarking on changing the description.