Class AbstractNode

java.lang.Object
  extended byAbstractNode
Direct Known Subclasses:
Node

public abstract class AbstractNode
extends java.lang.Object


Field Summary
(package private)  AbstractNode[] children
          The children array is either null, for leaf nodes, or it contains pointers to each child node.
(package private)  java.lang.Integer[] keys
          The keys array contains all the Integer keys in this node.
(package private) static int maxNumKeys
          This static class member indicates the maximum number of keys allowed in each node; it is set by the main program, and should not be changed after that.
(package private)  AbstractNode parent
          The parent pointer indicates the parent of this node.
(package private)  int x
          The x and y members are only used by the tree drawing class
(package private)  int y
           
 
Constructor Summary
(package private) AbstractNode(boolean _isLeaf, AbstractNode _parent)
          This is the standard constructor for BTree Nodes.
 
Method Summary
(package private) abstract  void delete(int i)
          The delete method removes a key value from the tree.
(package private)  void dumpTreeToText()
          This method outputs to standard out the a breadth-first text list of the keys in the tree.
(package private)  int getNumKeys()
          This method gets the number of keys present in the node, which should be between numKeys (the max value), and numKeys/2
(package private) abstract  void insert(int i)
          The insert method inserts a new key value into the tree.
(package private) abstract  boolean search(int i)
          The search method returns a boolean value indicating whether a certain key was found in the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxNumKeys

static int maxNumKeys
This static class member indicates the maximum number of keys allowed in each node; it is set by the main program, and should not be changed after that.


keys

java.lang.Integer[] keys
The keys array contains all the Integer keys in this node. If the node is only partly full, the remaining array entries contain null.


children

AbstractNode[] children
The children array is either null, for leaf nodes, or it contains pointers to each child node. If this node has fewer than the maximum number of children, the remaining array entries contain null.


parent

AbstractNode parent
The parent pointer indicates the parent of this node. If the node is the root, the parent is null


x

int x
The x and y members are only used by the tree drawing class


y

int y
Constructor Detail

AbstractNode

AbstractNode(boolean _isLeaf,
             AbstractNode _parent)
This is the standard constructor for BTree Nodes. It takes a parent node (which is null for the root node), and a boolean flag indicating whether the node is a (meaning that it will have no children).

Parameters:
_isLeaf - True if the node is a leaf node, and thus has no children.
Method Detail

getNumKeys

int getNumKeys()
This method gets the number of keys present in the node, which should be between numKeys (the max value), and numKeys/2

Returns:
an int value giving the number of keys

dumpTreeToText

void dumpTreeToText()
This method outputs to standard out the a breadth-first text list of the keys in the tree.


search

abstract boolean search(int i)
The search method returns a boolean value indicating whether a certain key was found in the tree.

Parameters:
i - The key to search for.
Returns:
Either true, if the key was found, or false if it was not.

insert

abstract void insert(int i)
The insert method inserts a new key value into the tree. If the key is already present, the tree does not change.

Parameters:
i - The key to insert.

delete

abstract void delete(int i)
The delete method removes a key value from the tree. If the key is not present, the tree does not change.

Parameters:
i - The key to remove.