public class

AStar.Iterator

extends Object
implements Iterator<E>
java.lang.Object
   ↳ es.usc.citius.hipster.algorithm.AStar.Iterator

Class Overview

Internal iterator that implements all the logic of the A* search

Summary

Fields
protected Map<S, N extends HeuristicNode<A, S, C extends Comparable<C>, N>> closed
protected Map<S, N extends HeuristicNode<A, S, C extends Comparable<C>, N>> open
protected Queue<N extends HeuristicNode<A, S, C extends Comparable<C>, N>> queue
Protected Constructors
AStar.Iterator()
Public Methods
Map<S, N> getClosed()
Get the internal map used by the algorithm to keep the relations between explored states and nodes.
Map<S, N> getOpen()
Get the internal map used by the algorithm to keep the relations between unexplored states and nodes.
Queue<N> getQueue()
Returns the original queue used by the algorithm to sort the unexplored nodes.
boolean hasNext()
Returns true if open queue is not empty.
N next()
Calculates the next visited state.
void remove()
Remove is not supported
void setClosed(Map<S, N> closed)
Replace the original close map with the provided one.
void setOpen(Map<S, N> open)
void setQueue(Queue<N> queue)
Replace the original open map with the provided one.
Protected Methods
N takePromising()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Iterator

Fields

protected Map<S, N extends HeuristicNode<A, S, C extends Comparable<C>, N>> closed

protected Map<S, N extends HeuristicNode<A, S, C extends Comparable<C>, N>> open

protected Queue<N extends HeuristicNode<A, S, C extends Comparable<C>, N>> queue

Protected Constructors

protected AStar.Iterator ()

Public Methods

public Map<S, N> getClosed ()

Get the internal map used by the algorithm to keep the relations between explored states and nodes. Modifications to the map can alter the normal function of the algorithm.

Returns
  • closed map with the explored nodes and states

public Map<S, N> getOpen ()

Get the internal map used by the algorithm to keep the relations between unexplored states and nodes. The map returned is the original copy. Modifications to the map can alter the normal function of the algorithm.

Returns
  • open map with the unexplored nodes and states.

public Queue<N> getQueue ()

Returns the original queue used by the algorithm to sort the unexplored nodes. The original queue is a java PriorityQueue. External modifications to the queue can cause malfunction. This method can be used for example to check the size of the queue during the search or to implement low level optimizations.

Returns
  • original copy of the internal queue.

public boolean hasNext ()

Returns true if open queue is not empty.

public N next ()

Calculates the next visited state. Each state contains the information of the partial path explored. To check if the state is the goal state, just check the corresponding node of the state with currentNode.transition().to().equals(myGoalState)

Returns
  • next visited state.

public void remove ()

Remove is not supported

public void setClosed (Map<S, N> closed)

Replace the original close map with the provided one. Modifications to the close map can cause malfunction. Use only for optimization purposes.

Parameters
closed internal close map.

public void setOpen (Map<S, N> open)

public void setQueue (Queue<N> queue)

Replace the original open map with the provided one. Modifications to the open map can cause malfunction. Use only for optimization purposes.

Parameters
queue internal open map.

Protected Methods

protected N takePromising ()