lojix/search/src/main/com/thesett/aima/search/SearchNode.java
public int expandSuccessors(Queue<SearchNode<O, T>> expandInto, boolean reverse) throws SearchNotExhaustiveException
    {
        // Used to keep count of the number of successors.
        int numSuccessors = 0;

        for (Iterator<Successor<O>> successors = getState().successors(reverse); successors.hasNext();)
        {
            numSuccessors++;

            // Get the next successor state
            Successor<O> next = successors.next();

            // Check if a repeated state filter is to be applied
            if (repeatedStateFilter != null)
            {
                // Filter the successor state and check if it should be accepted
                if (repeatedStateFilter.evaluate((T) next.getState(), this))
                {
                    // Add the filtered state to the successors
                    expandInto.offer(makeNode(next));
                }
            }

            // No repeated state filter is to be applied so add the successor state
            else
            {
                expandInto.offer(makeNode(next));
            }
        }

        // Successors have been expanded.
        expanded = true;

        return numSuccessors;
    }
public int expandSuccessors(Queue<SearchNode<O, T>> expandInto, boolean reverse) throws SearchNotExhaustiveException
    {
        // Used to keep count of the number of successors.
        int numSuccessors = 0;

        for (Iterator<Successor<O>> successors = getState().successors(reverse); successors.hasNext();)
        {
            numSuccessors++;

            // Get the next successor state
            Successor<O> next = successors.next();

            // Check if a repeated state filter is to be applied
            if (repeatedStateFilter != null)
            {
                // Filter the successor state and check if it should be accepted
                if (repeatedStateFilter.evaluate((T) next.getState(), this))
                {
                    // Add the filtered state to the successors
                    expandInto.offer(makeNode(next));
                }
            }

            // No repeated state filter is to be applied so add the successor state
            else
            {
                expandInto.offer(makeNode(next));
            }
        }

        // Successors have been expanded.
        expanded = true;

        return numSuccessors;
    }
Expands a node into its successors. The successors are added to the specified collection which is returned as the
result of this function. The reason that the collection is passed as an argument is that there are many different
styles of buffer (fifo, lifo, etc) that search functions can use to implement different kinds of search and it is
more efficient to expand directly into the buffer than to have to copy the results into it after this method is
called, which would be the case if this method returned a collection.

<p>If a repeated state filter has been attached to the search nodes then this method applies it here to all the
potential successor states. Only those that pass the filter are expanded into the collection.

@param  expandInto The collection to place the successors in.
@param  reverse    When set, indicates that the expansion should be done backwards.

@return The number of successor expanded.

@throws SearchNotExhaustiveException If the successor nodes cannot be created. This may happen when using a
custom node implementation that is not publicly accessible or that causes
other class loading/creation errors.