Facemorph.haar
Class DisjointSets

java.lang.Object
  extended by Facemorph.haar.DisjointSets

public class DisjointSets
extends java.lang.Object

A disjoint sets ADT. Performs union-by-rank and path compression. Implemented using arrays. There is no error checking whatsoever. By adding your own error-checking, you might save yourself a lot of time finding bugs in your application code for Project 3 and Homework 9. Without error-checking, expect bad things to happen if you try to unite two elements that are not roots of their respective sets, or are not distinct. Elements are represented by ints, numbered from zero.


Constructor Summary
DisjointSets(java.util.List objects)
          Construct a disjoint sets object.
 
Method Summary
 int find(int x)
          find() finds the (int) name of the set containing a given element.
static void groupRectangles(java.util.List<Face> rectList, java.util.ArrayList<java.lang.Integer> weights, int groupThreshold, double eps)
          Group a set of rectangle
static void groupRectangles(java.util.List<Face> rectList, int groupThreshold, double eps)
          Group a set of rectangle
static void groupRectangles(java.util.List<Face> rectList, int groupThreshold, double eps, java.util.ArrayList<java.lang.Integer> weights)
          Group a set of rectangle
static void main(java.lang.String[] args)
          main() is test code.
 void union(int root1, int root2)
          union() unites two disjoint sets into a single set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DisjointSets

public DisjointSets(java.util.List objects)
Construct a disjoint sets object.

Parameters:
objects - the elements to put into the sets
Method Detail

union

public void union(int root1,
                  int root2)
union() unites two disjoint sets into a single set. A union-by-rank heuristic is used to choose the new root. This method will corrupt the data structure if root1 and root2 are not roots of their respective sets, or if they're identical.

Parameters:
root1 - the root of the first set.
root2 - the root of the other set.

find

public int find(int x)
find() finds the (int) name of the set containing a given element. Performs path compression along the way.

Parameters:
x - the element sought.
Returns:
the set containing x.

groupRectangles

public static void groupRectangles(java.util.List<Face> rectList,
                                   int groupThreshold,
                                   double eps,
                                   java.util.ArrayList<java.lang.Integer> weights)
Group a set of rectangle

Parameters:
rectList - the list of rectangles
groupThreshold - the threshold count
eps - an error parameter
weights - list of counts

groupRectangles

public static void groupRectangles(java.util.List<Face> rectList,
                                   int groupThreshold,
                                   double eps)
Group a set of rectangle

Parameters:
rectList - the list of rectangles
groupThreshold - the threshold count
eps - an error parameter

groupRectangles

public static void groupRectangles(java.util.List<Face> rectList,
                                   java.util.ArrayList<java.lang.Integer> weights,
                                   int groupThreshold,
                                   double eps)
Group a set of rectangle

Parameters:
rectList - the list of rectangles
weights - list of counts
groupThreshold - the threshold count
eps - an error parameter

main

public static void main(java.lang.String[] args)
main() is test code. All the find()s on the same output line should be identical.

Parameters:
args - the program args