
Justin Gottschlich wrote:
Thus, any programmer using the tree could create an iterator for the tree to perform any kind of iteration they like (level iteration, tree-depth iteration, backwards tree-breadth iteration) and have standard algorithms work on that iterator exactly as they had coded. Thus, I wouldn't have to "pre-determine" all possible types of iterations (nor tree types) the end coder needs.
Some basic types of tree iteration clearly need to be available that I currently don't have. After the great points made today, I most certainly will add them. =)
When I read that it immediately made me think "policy based design". Would there perhaps be some way to make the iterator policy based? Then the user could use a core::tree::iterator<core::recursive>, or a core::tree::iterator<core::level_based>, or even a core::tree::iterator<core::reverse_level_based>. You could provide the more common iterator policies with your library. I don't know mechanically how this would be implemented, its just a thought. -Jason