Will a future version of BGL have a "TerminatorFunc" in all the visitor types? Throwing an exception as part of the "normal" flow of an algorithm seems to go against most people's C++ philosophy. On 22 Jun 2005, at 9:44 AM, Doug Gregor wrote:
On Jun 13, 2005, at 9:23 AM, martin f krafft wrote:
This may seem like a silly question, but how does one actually search with DFS or BFS? Say I want to find the first node for which a predicate returns true in a BFS traversal starting at node N...
The function signatures don't have a parameter for "criteria" or "predicate", so I guess it's up for a Visitor to implement such a check. What is not clear to me is how the visitor functions can break out of the search once a condition is true.
The typical way we handle this is to write a visitor that checks the predicate and, when it returns "true" just throw an exception. depth_first_visit actually has a "TerminatorFunc" parameter that does what you want, but it isn't present in the other search algorithms (although it probably should be).
Doug
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users