basic
Class SlowDepthFirstSearch<T>

java.lang.Object
  extended by core.Search<T>
      extended by core.DirectedSearch<T>
          extended by basic.SlowDepthFirstSearch<T>
Type Parameters:
T - the specific type of all elements in the search domain.
All Implemented Interfaces:
java.lang.Runnable

public class SlowDepthFirstSearch<T>
extends DirectedSearch<T>

A slow implementation of the depth first search algorithm which uses the general search algorithm implemented in the core.DirectedSearch. This depth first search algorithm is a blind search able to solve any problem implementing the core.Problem interface.

Note: This implementation is only for completeness and should not be used. Use the basic.DepthFirstSearch whenever you need to use a depth first search.

Author:
eden06
See Also:
DepthFirstSearch

Field Summary
 
Fields inherited from class core.DirectedSearch
hash, problem
 
Fields inherited from class core.Search
neededSteps, result
 
Constructor Summary
SlowDepthFirstSearch(Problem<T> problem)
          This method creates a new BreadthFirstSearch where implicit duplicate duplicate handling is enabled.
SlowDepthFirstSearch(Problem<T> problem, boolean noHash)
          This method creates a new SlowDepthFirstSearch.
 
Method Summary
protected  boolean add(T state)
          This method is the hook for adding new states to the queue during the search.
protected  void clear()
          This method is the hook for clearing the queue on preparation of a new search.
protected  boolean empty()
          This method is the hook for the check if the queue is empty during the search.
protected  T pop()
          This method is the hook for extracting the first element of the queue during the search.
 
Methods inherited from class core.DirectedSearch
branchedNodes, canPrepare, finalize, getProblem, prepare, search
 
Methods inherited from class core.Search
getResult, initialize, initialized, neededSteps, run, running, stop
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlowDepthFirstSearch

public SlowDepthFirstSearch(Problem<T> problem)
This method creates a new BreadthFirstSearch where implicit duplicate duplicate handling is enabled.

Parameters:
problem -

SlowDepthFirstSearch

public SlowDepthFirstSearch(Problem<T> problem,
                            boolean noHash)
This method creates a new SlowDepthFirstSearch. According to the given flag the search will turn off the internal duplicate handling mechanism or not.

Parameters:
problem - to be solved
noHash - flag indicating that duplicates should not be handled
Method Detail

add

protected boolean add(T state)
Description copied from class: DirectedSearch
This method is the hook for adding new states to the queue during the search.
After calling this method the state should be added to the queue.
Note: Most implementations do not check whether a state has been successfully added or not.

Specified by:
add in class DirectedSearch<T>
Parameters:
state - to be added to the queue
Returns:
true only if this state has been added.
See Also:
DirectedSearch.add(java.lang.Object)

clear

protected void clear()
Description copied from class: DirectedSearch
This method is the hook for clearing the queue on preparation of a new search.
It should remove all elements of the queue.

Specified by:
clear in class DirectedSearch<T>
See Also:
DirectedSearch.clear()

empty

protected boolean empty()
Description copied from class: DirectedSearch
This method is the hook for the check if the queue is empty during the search.
It should return true whenever the queue is empty.

Specified by:
empty in class DirectedSearch<T>
Returns:
true only if the queue is empty.
See Also:
DirectedSearch.empty()

pop

protected T pop()
Description copied from class: DirectedSearch
This method is the hook for extracting the first element of the queue during the search.
It should return and remove the first element of the queue.
Note: The implementation assures that this method will only be called if empty() returned false.

Specified by:
pop in class DirectedSearch<T>
Returns:
the first element of the queue
See Also:
DirectedSearch.pop()