goldman.partition
Interface PartitionElement<T>

All Known Implementing Classes:
UnionFindNode

public interface PartitionElement<T>

A partition is a division of a group of objects into disjoint sets that we call components. We view a partition abstractly as a collection of disjoint components whose union is the total collection. However, the actual data type we use to represent the partition is not the partition as a whole but rather the individual components of the collection. Each component in the partition is defined by an (arbitrary) element of that component known as the representative element, or simply the representative. So the data type that we implement for the Partition ADT is simply that of a PartitionElement that represents one element of the partition.


Method Summary
 PartitionElement<T> findRepresentative()
          Returns the representative element for the component that includes this partition element.
 T get()
          Returns the data associated with this partition element.
 boolean sameComponent(PartitionElement<T> x)
          Returns true if and only if this partition element and x are in the same component.
 void set(T applicationData)
          Returns a string that describes the data associated with this partition element.
 String toString()
           
 PartitionElement<T> union(PartitionElement<T> x)
          Combines the components holding this partition element and x into a single component.
 

Method Detail

findRepresentative

PartitionElement<T> findRepresentative()
Returns the representative element for the component that includes this partition element.


get

T get()
Returns the data associated with this partition element.


sameComponent

boolean sameComponent(PartitionElement<T> x)
Returns true if and only if this partition element and x are in the same component.


set

void set(T applicationData)
Returns a string that describes the data associated with this partition element.


toString

String toString()
Overrides:
toString in class Object

union

PartitionElement<T> union(PartitionElement<T> x)
Combines the components holding this partition element and x into a single component. It returns the representative element for the resulting component. If this element and x are already in the same component, no mutation occurs and their representative is returned.