lojix/search/src/main/com/thesett/aima/search/impl/BaseQueueSearch.java
public Queue<SearchNode<O, T>> enqueueStartStates(Collection<T> startStates)
    {
        // Check that there are some start states
        if (!startStates.isEmpty())
        {
            // Only enqueue the start states if they have not already been enqueued.
            if (!enqueuedOnce)
            {
                // Enqueue all the start states
                for (T nextStartState : startStates)
                {
                    // If the goal predicate has not been defined, try to set up the default from the initial search
                    // states.
                    if (goalPredicate == null)
                    {
                        goalPredicate = nextStartState.getDefaultGoalPredicate();
                    }

                    // Make search nodes out of the start states using the abstract search node creation method,
                    // subclasses override this to create different kinds of search node.
                    SearchNode newStartNode = createSearchNode(nextStartState);

                    // Check if a repeated state filter has been applied and attach it to the start node if so.
                    if (repeatedStateFilter != null)
                    {
                        // Attach it to the start node.
                        newStartNode.setRepeatedStateFilter(repeatedStateFilter);
                    }

                    // Insert the new start search node onto the queue.
                    queue.offer(newStartNode);
                }
            }
        }
        else
        {
            // There are no start states so raise an exception because the search cannot be run without a start state.
            throw new IllegalStateException("Cannot start the search because there are no start states defined. " +
                "Queue searches require some start states.", null);
        }

        // Check that a goal predicate is set up.
        if (goalPredicate == null)
        {
            throw new IllegalStateException("Cannot start the search because there is no goal predicate.", null);
        }

        // Set the enqueuedOnce flag to indicate that the start states have already been enqueued.
        enqueuedOnce = true;

        return queue;
    }
public Queue<SearchNode<O, T>> enqueueStartStates(Collection<T> startStates)
    {
        // Check that there are some start states
        if (!startStates.isEmpty())
        {
            // Only enqueue the start states if they have not already been enqueued.
            if (!enqueuedOnce)
            {
                // Enqueue all the start states
                for (T nextStartState : startStates)
                {
                    // If the goal predicate has not been defined, try to set up the default from the initial search
                    // states.
                    if (goalPredicate == null)
                    {
                        goalPredicate = nextStartState.getDefaultGoalPredicate();
                    }

                    // Make search nodes out of the start states using the abstract search node creation method,
                    // subclasses override this to create different kinds of search node.
                    SearchNode newStartNode = createSearchNode(nextStartState);

                    // Check if a repeated state filter has been applied and attach it to the start node if so.
                    if (repeatedStateFilter != null)
                    {
                        // Attach it to the start node.
                        newStartNode.setRepeatedStateFilter(repeatedStateFilter);
                    }

                    // Insert the new start search node onto the queue.
                    queue.offer(newStartNode);
                }
            }
        }
        else
        {
            // There are no start states so raise an exception because the search cannot be run without a start state.
            throw new IllegalStateException("Cannot start the search because there are no start states defined. " +
                "Queue searches require some start states.", null);
        }

        // Check that a goal predicate is set up.
        if (goalPredicate == null)
        {
            throw new IllegalStateException("Cannot start the search because there is no goal predicate.", null);
        }

        // Set the enqueuedOnce flag to indicate that the start states have already been enqueued.
        enqueuedOnce = true;

        return queue;
    }
public Queue < SearchNode < O , T > > enqueueStartStates ( Collection < T > startStates ) { // Check that there are some start states if ( ! startStates . isEmpty ( ) ) { // Only enqueue the start states if they have not already been enqueued. if ( ! enqueuedOnce ) { // Enqueue all the start states for ( T nextStartState : startStates ) { // If the goal predicate has not been defined, try to set up the default from the initial search // states. if ( goalPredicate == null ) { goalPredicate = nextStartState . getDefaultGoalPredicate ( ) ; } // Make search nodes out of the start states using the abstract search node creation method, // subclasses override this to create different kinds of search node. SearchNode newStartNode = createSearchNode ( nextStartState ) ; // Check if a repeated state filter has been applied and attach it to the start node if so. if ( repeatedStateFilter != null ) { // Attach it to the start node. newStartNode . setRepeatedStateFilter ( repeatedStateFilter ) ; } // Insert the new start search node onto the queue. queue . offer ( newStartNode ) ; } } } else { // There are no start states so raise an exception because the search cannot be run without a start state. throw new IllegalStateException ( "Cannot start the search because there are no start states defined. " + "Queue searches require some start states." , null ) ; } // Check that a goal predicate is set up. if ( goalPredicate == null ) { throw new IllegalStateException ( "Cannot start the search because there is no goal predicate." , null ) ; } // Set the enqueuedOnce flag to indicate that the start states have already been enqueued. enqueuedOnce = true ; return queue ; }
This logic enqueues all the start states, calling the {@link #createSearchNode} method that concrete sub-classes
implement to specify the search node type. If there is a repeated state filter set up then this is attached to
the search nodes. This is called at the start of the search method to set up the queue into a state which is
ready for the search algorithm.

@param  startStates The set of start states to being the search at.

@return The queue of search nodes for each of the start states.

@throws IllegalStateException if no start states have been set for the search.
This logic enqueues all the start states calling the { @link #createSearchNode } method that concrete sub - classes implement to specify the search node type . If there is a repeated state filter set up then this is attached to the search nodes . This is called at the start of the search method to set up the queue into a state which is ready for the search algorithm .