Algorithm
Development Kit 1.0

algs.model.searchtree
Interface INodeSet

All Known Implementing Classes:
ClosedStates, StateHash, StateOrdered, StateQueue, StateStack, StateTree

public interface INodeSet

Defines an interface by which sets of INode objects are accessed.

Define this instead of, say, using the Collection approach because it will be simpler, and because there are some domain specific operations appropriate for sets of INode that are not immediately supported by the JDK package.

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

Method Summary
 INode contains(INode n)
          Return the actual node in storage that is equal to the given node.
 void insert(INode n)
          Inserts node based on inherent behavior.
 boolean isEmpty()
          Is collection empty.
 java.util.Iterator<INode> iterator()
          Return iterator to the existing board states.
 INode remove()
          Remove minimum node based on inherent behavior.
 boolean remove(INode n)
          Remove node from node set.
 int size()
          Return the number of states in the set.
 

Method Detail

isEmpty

boolean isEmpty()
Is collection empty.


size

int size()
Return the number of states in the set.


contains

INode contains(INode n)
Return the actual node in storage that is equal to the given node.

The signature of this method may look odd. Recall that If the node doesn't exist then return null.

Parameters:
n - Board state to be inspected

iterator

java.util.Iterator<INode> iterator()
Return iterator to the existing board states.


remove

INode remove()
Remove minimum node based on inherent behavior. Changes based on the subtype. If a queue, then removes first; If a stack, then removes topmost element on the stack.


remove

boolean remove(INode n)
Remove node from node set.

The parameter is either an actual node in the node set or a copy of one of its nodes.

Parameters:
n - Board state to be removed

insert

void insert(INode n)
Inserts node based on inherent behavior. Changes based on the subtype. If a queue, then added at the end; if a stack then inserted to be the topmost element on the stack.

It is the responsibility of the caller to ensure that the node does not already exist in the list, using the contains(INode) method.

Parameters:
n - Board state to be inserted

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.