/*
* Created on Jul 6, 2004
*/
package treeDraw;
/** A node suitable for use by linked lists, binary trees, general trees,
* or any such structure characterized by a number of links to other
* linked nodes.
*
* Implementing classes should provide constructors of these forms:
*
* public classname(type anObject);
*
*
* public classname(type anObject, ILink next); //set child(0)
*
* public classname(type anObject, ILink left, ILink right); set child(0) and (1)
*
* @author dickey
*/
public interface INode {
/** A convenience method which should return the same as getChild(0)
* @return a node (which may be null)
*/
INode getLeft();
/** A convenience method which should return the same as getChild(1)
* @return a node (which may be null)
*/
INode getRight();
/** Tells how many children this node may have. For example, for a
* a binary tree, it would be a constant 2.
* @return the maximum number of nodes allowed for this child, or
* -1 if there is no limit.
*/
int getMaxChildCount();
/** Tells how many non-null children this node currently has.
* @return number of non-null children, always >= 0.
*/
int getChildCount();
/** Returns the node indicated, which may be null. Nodes are
* numbered from 0 left to right. In a binary tree,
* getChild(0) should return the left node and getChild(1)
* should return the right node.
* @param childIndex a value >= and < getMaxChildCount.
* @return the node, which may be null.
*/
INode getChild(int childIndex);
/** Convenience method for setChild(0, leftNode).
*
* @param leftNode any node, which might be null.
*/
void setLeft(INode leftNode);
/** Convenience method for setChild(1,rightNode).
*
* @param rightNode any node, which might be null.
*/
void setRight(INode rightNode);
/** Set the child to the given node value. Nodes are numbered
* left to right from 0. The node may be null.
* @param link
* @param childIndex
*/
void setChild(INode link, int childIndex);
/** Set the element value of this node, replaced whatever
* was there.
* @param anObject any object, which may be null.
*/
void setValue(Object anObject);
/** Get the element value of this node, which may be null.
*
* @return the value currently stored at this node. No changes
* are made to the node.
*/
Object getValue();
}