While studying the pattern of visitor design, I found this sentence:
You can use Visitor with iterator to traverse a complex data structure and perform some operations on its elements, even if they all have different classes.
Pattern for visitor design
When searching the internet, if it was a good idea, I found different opinions. Some said that you can combine the two patterns:
You can combine both perfectly: Use an iterator to move over each element of a data structure and pass a visitor to each element so that an external person in charge can execute the element.
Iterator vs. visitors
Others said that you can do this, but it depends on the complexity of the operation:
The visitor as such is not "unnecessary" if you have an iterator. This depends on the complexity of the operations you want to apply to the elements you are going through.
Iterator and visitors
I wonder in which situation it makes sense to have such a combination of patterns. What kind of operation is considered complex?