Opus5
Class PartitionAsForest.PartitionTree

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.AbstractContainer
              |
              +--Opus5.AbstractSearchableContainer
                    |
                    +--Opus5.AbstractSet
                          |
                          +--Opus5.PartitionAsForest.PartitionTree
All Implemented Interfaces:
Comparable, Container, SearchableContainer, Set, Tree
Enclosing class:
PartitionAsForest

protected class PartitionAsForest.PartitionTree
extends AbstractSet
implements Set, Tree

A node in a partition tree. A partition tree is an element of a partition.

Version:
$Id: PartitionAsForest.java,v 3.6 1998/07/28 19:14:43 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
Partition

Field Summary
protected  int item
          An element of the universal set.
protected  PartitionAsForest.PartitionTree parent
          The parent of this node.
protected  int rank
          The rank of this node.
 
Fields inherited from class Opus5.AbstractSet
universeSize
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.Set
copyright
 
Fields inherited from interface Opus5.Tree
copyright
 
Constructor Summary
PartitionAsForest.PartitionTree(int item)
          Constructs a PartitionTree for the specified element of the universal set a the specified size of universal set.
 
Method Summary
 void breadthFirstTraversal(Visitor visitor)
          Does a breadth-first traversal of this partition tree.
protected  int compareTo(Comparable object)
          Compares this partition tree node with the specified comparable object.
 void depthFirstTraversal(PrePostVisitor visitor)
          Does a depth-first traversal of this partition tree.
 Set difference(Set set)
          Returns the difference between the set represented by this partition tree and the specified set.
 int getDegree()
          Returns the degree of this partition tree node.
 Enumeration getEnumeration()
          Returns an enumeration that enumerates the elements of this partition tree.
 int getHeight()
          Returns the height (rank) of this partition tree.
 java.lang.Object getKey()
          Returns the key in this partition tree node.
 Tree getSubtree(int i)
          Returns the specified subtree of this partition tree node.
 int hashCode()
          Returns a hashcode for this partition tree node.
protected  void insert(int i)
          Undefined for partition trees.
 Set intersection(Set set)
          Returns the intersection of the set represented by this partition tree and the specified set.
 boolean isEmpty()
          Tests whether this partition tree node is empty.
 boolean isEQ(Set set)
          Tests whether the set represented by this partition tree is equal to the specified set.
 boolean isLeaf()
          Tests whether this partition tree node is a leaf node.
protected  boolean isMember(int i)
          Tests whether the specified item is an element of this partition tree.
protected  boolean IsMemberOf(PartitionAsForest partition)
          Tests whether this partition tree is an element of the specified partition.
 boolean isSubset(Set set)
          Tests whether the set represented by this partition tree is a subset of the specified set.
 void purge()
          Purges this partition tree node, making it into a singleton.
protected  void setCount(int count)
          Sets the count field to the specified value.
 java.lang.String toString()
          Returns a string representation of this partition tree.
 Set union(Set set)
          Returns the union of the set represented by this partition tree and the specified set.
protected  void withdraw(int i)
          Undefined for partition trees.
 
Methods inherited from class Opus5.AbstractSet
find, insert, isMember, withdraw
 
Methods inherited from class Opus5.AbstractContainer
accept, getCount, isFull
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.SearchableContainer
find, insert, isMember, withdraw
 
Methods inherited from interface Opus5.Container
accept, getCount, isFull
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

item

protected int item
An element of the universal set.

parent

protected PartitionAsForest.PartitionTree parent
The parent of this node.

rank

protected int rank
The rank of this node.
Constructor Detail

PartitionAsForest.PartitionTree

public PartitionAsForest.PartitionTree(int item)
Constructs a PartitionTree for the specified element of the universal set a the specified size of universal set.
Parameters:
item - An element of the universal set.
Method Detail

purge

public void purge()
Purges this partition tree node, making it into a singleton.
Specified by:
purge in interface Container

setCount

protected void setCount(int count)
Sets the count field to the specified value.
Parameters:
count - The desired value.

IsMemberOf

protected boolean IsMemberOf(PartitionAsForest partition)
Tests whether this partition tree is an element of the specified partition.
Parameters:
partition - The specified partition.
Returns:
True if this partition tree is an element of the specified partition; false otherwise.

getHeight

public int getHeight()
Returns the height (rank) of this partition tree.
Specified by:
getHeight in interface Tree
Returns:
The height (rank) of this partition tree.

getKey

public java.lang.Object getKey()
Returns the key in this partition tree node.
Specified by:
getKey in interface Tree
Returns:
The key in this partition tree node.

compareTo

protected int compareTo(Comparable object)
Compares this partition tree node with the specified comparable object. The specified comparable object is assumed to be a PartitionTree instance. The result is obtained by comparing the keys in the respective partition tree nodes.
Overrides:
compareTo in class AbstractObject
Parameters:
object - The comparable object with which to compare this partition tree.
Returns:
A number less than zero if the key in this node is less than that in the specified node; a number greater than zero if the key in this node is greater than that in the specified node; zero if the two keys are equal.

hashCode

public int hashCode()
Returns a hashcode for this partition tree node.
Overrides:
hashCode in class AbstractContainer
Returns:
The value of element of the universal set in this node.

toString

public java.lang.String toString()
Returns a string representation of this partition tree.
Overrides:
toString in class AbstractContainer
Returns:
A string representation of this partition tree.

insert

protected void insert(int i)
Undefined for partition trees.
Overrides:
insert in class AbstractSet
Throws:
InvalidOperationException - Always.

withdraw

protected void withdraw(int i)
Undefined for partition trees.
Overrides:
withdraw in class AbstractSet
Throws:
InvalidOperationException - Always.

isMember

protected boolean isMember(int i)
Tests whether the specified item is an element of this partition tree. This method is not implemented.
Overrides:
isMember in class AbstractSet
Throws:
MethodNotImplemented - Always.

isLeaf

public boolean isLeaf()
Tests whether this partition tree node is a leaf node. This method is not implemented.
Specified by:
isLeaf in interface Tree
Throws:
MethodNotImplemented - Always.

isEmpty

public boolean isEmpty()
Tests whether this partition tree node is empty.
Specified by:
isEmpty in interface Container
Overrides:
isEmpty in class AbstractContainer
Returns:
False always.

getSubtree

public Tree getSubtree(int i)
Returns the specified subtree of this partition tree node.
Specified by:
getSubtree in interface Tree
Throws:
MethodNotImplemented - Always.

getDegree

public int getDegree()
Returns the degree of this partition tree node.
Specified by:
getDegree in interface Tree
Throws:
MethodNotImplemented - Always.

depthFirstTraversal

public void depthFirstTraversal(PrePostVisitor visitor)
Does a depth-first traversal of this partition tree.
Specified by:
depthFirstTraversal in interface Tree
Throws:
MethodNotImplemented - Always.

breadthFirstTraversal

public void breadthFirstTraversal(Visitor visitor)
Does a breadth-first traversal of this partition tree.
Specified by:
breadthFirstTraversal in interface Tree
Throws:
MethodNotImplemented - Always.

union

public Set union(Set set)
Returns the union of the set represented by this partition tree and the specified set.
Specified by:
union in interface Set
Throws:
MethodNotImplemented - Always.

intersection

public Set intersection(Set set)
Returns the intersection of the set represented by this partition tree and the specified set.
Specified by:
intersection in interface Set
Throws:
MethodNotImplemented - Always.

difference

public Set difference(Set set)
Returns the difference between the set represented by this partition tree and the specified set.
Specified by:
difference in interface Set
Throws:
MethodNotImplemented - Always.

isEQ

public boolean isEQ(Set set)
Tests whether the set represented by this partition tree is equal to the specified set.
Specified by:
isEQ in interface Set
Throws:
MethodNotImplemented - Always.

isSubset

public boolean isSubset(Set set)
Tests whether the set represented by this partition tree is a subset of the specified set.
Specified by:
isSubset in interface Set
Throws:
MethodNotImplemented - Always.

getEnumeration

public Enumeration getEnumeration()
Returns an enumeration that enumerates the elements of this partition tree.
Specified by:
getEnumeration in interface Container
Throws:
MethodNotImplemented - Always.