prefuse.data.util
Class TupleComparator

java.lang.Object
  extended by prefuse.data.util.TupleComparator
All Implemented Interfaces:
java.util.Comparator

public class TupleComparator
extends java.lang.Object
implements java.util.Comparator

Comparator that compares Tuples based on the value of a single field.

Author:
jeffrey heer

Constructor Summary
TupleComparator(int col, java.lang.Class type, boolean ascend)
          Creates a new TupleComparator.
TupleComparator(int col, java.lang.Class type, boolean ascend, java.util.Comparator c)
          Creates a new TupleComparator.
TupleComparator(java.lang.String field, java.lang.Class type, boolean ascend)
          Creates a new TupleComparator.
TupleComparator(java.lang.String field, java.lang.Class type, boolean ascend, java.util.Comparator c)
          Creates a new TupleComparator.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two tuples.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

TupleComparator

public TupleComparator(java.lang.String field,
                       java.lang.Class type,
                       boolean ascend)
Creates a new TupleComparator.

Parameters:
field - the data field to compare
type - the expected type of the data field
ascend - true to sort in ascending order, false for descending

TupleComparator

public TupleComparator(java.lang.String field,
                       java.lang.Class type,
                       boolean ascend,
                       java.util.Comparator c)
Creates a new TupleComparator.

Parameters:
field - the data field to compare
type - the expected type of the data field
ascend - true to sort in ascending order, false for descending
c - the comparator to use. Note that for primitive types, this should be an instance of LiteralComparator, otherwise subequent errors will occur.

TupleComparator

public TupleComparator(int col,
                       java.lang.Class type,
                       boolean ascend)
Creates a new TupleComparator.

Parameters:
col - the column number of the data field to compare
type - the expected type of the data field
ascend - true to sort in ascending order, false for descending

TupleComparator

public TupleComparator(int col,
                       java.lang.Class type,
                       boolean ascend,
                       java.util.Comparator c)
Creates a new TupleComparator.

Parameters:
col - the column number of the data field to compare
type - the expected type of the data field
ascend - true to sort in ascending order, false for descending
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two tuples. If either input Object is not a Tuple, a ClassCastException will be thrown.

Specified by:
compare in interface java.util.Comparator
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)


Copyright © 2007 Regents of the University of California