Class Element

java.lang.Object
  extended byElement

public class Element
extends java.lang.Object

This class is used for implementing and manipulating a tree representation of a generic set, which allows for efficient union and find-set operations. See the comment for the Set class for more information on the structure of a set.
Each Element instance is a node in the tree set representation. It stores the value of the element; if it is not the root of the tree then it has a reference to its parent Element in the tree, if it is the root of the tree (i.e., it is the set representative) then it has a reference to the Set instance of the set for the tree. The Element class also implements a findSet() method that returns a reference to the Set instance of the set that contains this Element.


Field Summary
static boolean usePathCompression
          This parameter specifies whether path compression is applied whenever a find-set operation is performed.
 
Constructor Summary
Element(java.lang.Object v)
          This is the constructor method for Element class.
 
Method Summary
 Set findSet()
          This method returns a reference to the Set instance of the set that contains this Element.
 java.lang.Object getParentElmnt()
          This method returns the parent of the Element.
 java.lang.Object getValue()
          This method returns the value of the Element.
 void setParentElmnt(Element newParent)
          This method sets the parent of the Element.
 java.lang.String toString()
          Overwrite default toString() method to print Element info.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

usePathCompression

public static boolean usePathCompression
This parameter specifies whether path compression is applied whenever a find-set operation is performed.

Constructor Detail

Element

public Element(java.lang.Object v)
This is the constructor method for Element class. It initializes the Element's value to v, and constructs a new singleton set that contains this Element.

Parameters:
v - the Element's value
Method Detail

toString

public java.lang.String toString()
Overwrite default toString() method to print Element info.


getValue

public java.lang.Object getValue()
This method returns the value of the Element.

Returns:
the Element's value.

getParentElmnt

public java.lang.Object getParentElmnt()
This method returns the parent of the Element.

Returns:
the parent.

setParentElmnt

public void setParentElmnt(Element newParent)
This method sets the parent of the Element.

Parameters:
newParent - the new parent Object.

findSet

public Set findSet()
This method returns a reference to the Set instance of the set that contains this Element.

Returns:
the Set instance of the set containing this Element