Opus5
Class PartitionAsForest

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.AbstractContainer
              |
              +--Opus5.AbstractSearchableContainer
                    |
                    +--Opus5.AbstractSet
                          |
                          +--Opus5.PartitionAsForest
All Implemented Interfaces:
Comparable, Container, Partition, SearchableContainer, Set
Direct Known Subclasses:
PartitionAsForestV2

public class PartitionAsForest
extends AbstractSet
implements Partition

A partition implemented as a forest of trees.

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

Inner Class Summary
protected  class PartitionAsForest.PartitionTree
          A node in a partition tree.
 
Field Summary
protected  PartitionAsForest.PartitionTree[] array
          Array of partition trees.
 
Fields inherited from class Opus5.AbstractSet
universeSize
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.Partition
copyright
 
Constructor Summary
PartitionAsForest(int n)
          Constructs a PartitionAsForest with the specified number of elements in its universal set.
 
Method Summary
 void accept(Visitor visitor)
          Accepts a visitor and makes it visit the elements of this partition.
protected  void checkArguments(PartitionAsForest.PartitionTree s, PartitionAsForest.PartitionTree t)
          Checks whether the specified partition trees are distinct, are both members of this partition, and are both roots of their respective trees.
protected  int compareTo(Comparable arg)
          Compares this partition with the specified comparable object.
 Set difference(Set set)
          Undefined for partitions.
 Comparable find(Comparable object)
          Finds the element of this partition that contains the specified element of the universal set.
 Set find(int item)
          Finds the element of this partition that contains the specified element of the universal set.
 Enumeration getEnumeration()
          Returns an enumeration that enumerates the elements of this partition.
protected  void insert(int i)
          Undefined for partitions.
 Set intersection(Set set)
          Undefined for partitions.
 boolean isEQ(Set set)
          Tests whether this partition is equal to the specified set.
 boolean isMember(Comparable object)
          Tests whether the given comparable object is a member of this partition.
protected  boolean isMember(int i)
          Undefined for partitions.
 boolean isSubset(Set set)
          Tests whether this partition is a subset of the specified set.
 void join(Set s, Set t)
          Joins the specified elements of this partition.
 void purge()
          Purges the partition, placing each element of the universal set into its own element of the partition.
 Set union(Set set)
          Undefined for partitions.
protected  void withdraw(int i)
          Undefined for partitions.
 
Methods inherited from class Opus5.AbstractSet
insert, withdraw
 
Methods inherited from class Opus5.AbstractContainer
getCount, hashCode, isEmpty, isFull, toString
 
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
insert, withdraw
 
Methods inherited from interface Opus5.Container
getCount, isEmpty, isFull
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

array

protected PartitionAsForest.PartitionTree[] array
Array of partition trees.
Constructor Detail

PartitionAsForest

public PartitionAsForest(int n)
Constructs a PartitionAsForest with the specified number of elements in its universal set.
Parameters:
n - The size of elements in the universal set.
Method Detail

purge

public void purge()
Purges the partition, placing each element of the universal set into its own element of the partition.
Specified by:
purge in interface Container

find

public Set find(int item)
Finds the element of this partition that contains the specified element of the universal set.
Specified by:
find in interface Partition
Parameters:
item - The element of the universal set for which to look.
Returns:
The element of this partition that contains the specified element of the universal set.

find

public Comparable find(Comparable object)
Finds the element of this partition that contains the specified element of the universal set. In this case, the argument is a comparable object that is assumed to be a Int instance that specifies the element of the universal set.
Specified by:
find in interface SearchableContainer
Overrides:
find in class AbstractSet
Parameters:
object - An Int that specifies the desired element of the universal set.
Returns:
The element of this partition that contains the specified element of the universal set.

checkArguments

protected void checkArguments(PartitionAsForest.PartitionTree s,
                              PartitionAsForest.PartitionTree t)
Checks whether the specified partition trees are distinct, are both members of this partition, and are both roots of their respective trees.
Parameters:
s - A partition tree.
t - A partition tree.
Throws:
java.lang.IllegalArgumentException - If any condition above is violated.

join

public void join(Set s,
                 Set t)
Joins the specified elements of this partition. It is assumed that both arguments are elements of this partition.
Specified by:
join in interface Partition
Parameters:
s - An element of this partition.
t - An element of this partition.

isMember

public boolean isMember(Comparable object)
Tests whether the given comparable object is a member of this partition.
Specified by:
isMember in interface SearchableContainer
Overrides:
isMember in class AbstractSet
Parameters:
object - The object for which to look.
Returns:
True if the object is a member of this partition; false otherwise.

accept

public void accept(Visitor visitor)
Accepts a visitor and makes it visit the elements of this partition.
Specified by:
accept in interface Container
Overrides:
accept in class AbstractContainer
Parameters:
visitor - The visitor to accept.

insert

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

withdraw

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

isMember

protected boolean isMember(int i)
Undefined for partitions.
Overrides:
isMember in class AbstractSet
Throws:
InvalidOperationException - Always.

getEnumeration

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

union

public Set union(Set set)
Undefined for partitions.
Specified by:
union in interface Set
Throws:
InvalidOperationException - Always.

intersection

public Set intersection(Set set)
Undefined for partitions.
Specified by:
intersection in interface Set
Throws:
InvalidOperationException - Always.

difference

public Set difference(Set set)
Undefined for partitions.
Specified by:
difference in interface Set
Throws:
InvalidOperationException - Always.

isEQ

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

isSubset

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

compareTo

protected int compareTo(Comparable arg)
Compares this partition with the specified comparable object. This method is not implemented.
Overrides:
compareTo in class AbstractObject
Parameters:
object - The object with which this partition is compared.
Throws:
MethodNotImplemented - Always.