Algorithm
Development Kit 1.0

algs.model.searchtree.states
Class StateOrdered

java.lang.Object
  extended by algs.model.searchtree.states.StateOrdered
All Implemented Interfaces:
INodeSet

public class StateOrdered
extends java.lang.Object
implements INodeSet

Maintains the set of open states in ordered fashion, so the state with the lowest evaluation function can be removed. This straw man implementation using linked lists to store the information, thus the key operations are:

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Constructor Summary
StateOrdered()
          Store states using double linked list.
 
Method Summary
 INode contains(INode n)
          Determine if contained within the set.
 void insert(INode n)
          Insert the board state into the set.
 boolean isEmpty()
          Is collection empty.
 java.util.Iterator<INode> iterator()
          Return iterator to the existing board states.
 INode remove()
          Remove board state with lowest evaluated score.
 boolean remove(INode n)
          Remove from the set.
 int size()
          Return the number of states in the set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateOrdered

public StateOrdered()
Store states using double linked list.

Method Detail

insert

public void insert(INode n)
Insert the board state into the set.

Specified by:
insert in interface INodeSet
Parameters:
n -

isEmpty

public boolean isEmpty()
Description copied from interface: INodeSet
Is collection empty.

Specified by:
isEmpty in interface INodeSet

size

public int size()
Description copied from interface: INodeSet
Return the number of states in the set.

Specified by:
size in interface INodeSet

iterator

public java.util.Iterator<INode> iterator()
Description copied from interface: INodeSet
Return iterator to the existing board states.

Specified by:
iterator in interface INodeSet

remove

public INode remove()
Remove board state with lowest evaluated score.

Specified by:
remove in interface INodeSet

contains

public INode contains(INode n)
Determine if contained within the set.

An existing INode in the set that .equals(n) is selected and returned.

Specified by:
contains in interface INodeSet
Parameters:
n - the desired node.

remove

public boolean remove(INode n)
Remove from the set.

An existing INode in the set that .equals(n) is selected for removal.

Specified by:
remove in interface INodeSet
Parameters:
n - the INode to be removed from the set.

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.