lojix/search/src/main/com/thesett/aima/search/util/Searches.java
public static <O, T extends Traversable<O>> Iterator<SearchNode<O, T>> allSolutionPaths(
        QueueBasedSearchMethod<O, T> method)
    {
        // Take a final reference to the search method to use from within the inner class.
        final QueueBasedSearchMethod<O, T> search = method;

        return new SequenceIterator<SearchNode<O, T>>()
            {
                /**
                 * Generates the next element in the search.
                 *
                 * @return The next solution from the search if one is available, or <tt>null</tt> if the search is
                 *         complete.
                 */
                public SearchNode<O, T> nextInSequence()
                {
                    try
                    {
                        return search.findGoalPath();
                    }
                    catch (SearchNotExhaustiveException e)
                    {
                        // SearchNotExhaustiveException means that the search has completed within its designed parameters
                        // without exhausting the search space. Consequently there are no more solutions to find,
                        // the exception can be ignored and the sequence correctly terminated.
                        e = null;

                        return null;
                    }
                }
            };
    }
public static <O, T extends Traversable<O>> Iterator<SearchNode<O, T>> allSolutionPaths(
        QueueBasedSearchMethod<O, T> method)
    {
        // Take a final reference to the search method to use from within the inner class.
        final QueueBasedSearchMethod<O, T> search = method;

        return new SequenceIterator<SearchNode<O, T>>()
            {
                /**
                 * Generates the next element in the search.
                 *
                 * @return The next solution from the search if one is available, or <tt>null</tt> if the search is
                 *         complete.
                 */
                public SearchNode<O, T> nextInSequence()
                {
                    try
                    {
                        return search.findGoalPath();
                    }
                    catch (SearchNotExhaustiveException e)
                    {
                        // SearchNotExhaustiveException means that the search has completed within its designed parameters
                        // without exhausting the search space. Consequently there are no more solutions to find,
                        // the exception can be ignored and the sequence correctly terminated.
                        e = null;

                        return null;
                    }
                }
            };
    }
public static < O , T extends Traversable < O > > Iterator < SearchNode < O , T > > allSolutionPaths ( QueueBasedSearchMethod < O , T > method ) { // Take a final reference to the search method to use from within the inner class. final QueueBasedSearchMethod < O , T > search = method ; return new SequenceIterator < SearchNode < O , T > > ( ) { /**
                 * Generates the next element in the search.
                 *
                 * @return The next solution from the search if one is available, or <tt>null</tt> if the search is
                 *         complete.
                 */ public SearchNode < O , T > nextInSequence ( ) { try { return search . findGoalPath ( ) ; } catch ( SearchNotExhaustiveException e ) { // SearchNotExhaustiveException means that the search has completed within its designed parameters // without exhausting the search space. Consequently there are no more solutions to find, // the exception can be ignored and the sequence correctly terminated. e = null ; return null ; } } } ; }
Provides an iterator over a search method, that returns successive search solutions on demand.

@param  <O>    The operator type of the search.
@param  <T>    The traversable state type of the search.
@param  method The search method to iterate over.

@return An iterator over all solutions to the search.
Provides an iterator over a search method that returns successive search solutions on demand .