lojix/search/src/main/com/thesett/aima/search/util/Searches.java
public static <T> Iterator<T> allSolutions(SearchMethod<T> method)
    {
        //return new Filterator<SearchNode<O, T>, T>(allSolutionNodes(method), new ExtractSearchNode<O, T>());

        // Take a final reference to the search method to use from within the inner class.
        final SearchMethod<T> search = method;

        return new SequenceIterator<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 T nextInSequence()
                {
                    try
                    {
                        return search.search();
                    }
                    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 <T> Iterator<T> allSolutions(SearchMethod<T> method)
    {
        //return new Filterator<SearchNode<O, T>, T>(allSolutionNodes(method), new ExtractSearchNode<O, T>());

        // Take a final reference to the search method to use from within the inner class.
        final SearchMethod<T> search = method;

        return new SequenceIterator<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 T nextInSequence()
                {
                    try
                    {
                        return search.search();
                    }
                    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  <T>    The traversable state type of the search.
@param  method The search method to iterate over.

@return An iterator over all solution states to the search.