Package search
Class Frontiers.Queue<Node>
java.lang.Object
search.Frontiers.Queue<Node>
- All Implemented Interfaces:
FrontierCheckingStructure<Node>
,FrontierStructure<Node>
- Enclosing class:
- Frontiers
public static class Frontiers.Queue<Node> extends Object implements FrontierCheckingStructure<Node>
A queue as a priority queue, for e.g. BFS.
-
Constructor Summary
Constructors Constructor Description Queue()
-
Method Summary
Modifier and Type Method Description void
add(Node n)
Adds a (usually newly-generated) tree node to the frontier.boolean
contains(Node n)
int
countOpen()
Returns the number of open nodes sitting unexpanded in the frontier.boolean
isEmpty()
Checks whether any tree nodes remain in the frontierNode
pop()
Removes one tree node from the frontier, and returns it.
-
Constructor Details
-
Queue
public Queue()
-
-
Method Details
-
add
Description copied from interface:FrontierStructure
Adds a (usually newly-generated) tree node to the frontier.- Specified by:
add
in interfaceFrontierStructure<Node>
- Parameters:
n
- The new node
-
isEmpty
public boolean isEmpty()Description copied from interface:FrontierStructure
Checks whether any tree nodes remain in the frontier- Specified by:
isEmpty
in interfaceFrontierStructure<Node>
- Returns:
- false when the frontier is empty, which generally indicates that the search has failed.
-
pop
Description copied from interface:FrontierStructure
Removes one tree node from the frontier, and returns it.- Specified by:
pop
in interfaceFrontierStructure<Node>
- Returns:
- The dequeued tree node
-
countOpen
public int countOpen()Description copied from interface:FrontierStructure
Returns the number of open nodes sitting unexpanded in the frontier.- Specified by:
countOpen
in interfaceFrontierStructure<Node>
- Returns:
- The number of open nodes
-
contains
- Specified by:
contains
in interfaceFrontierCheckingStructure<Node>
-