prefuse.util.collections
Class CompositeComparator

java.lang.Object
  extended by prefuse.util.collections.CompositeComparator
All Implemented Interfaces:
java.util.Comparator

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

Comparator that makes comparison using an ordered list of individual comparators;

Author:
jeffrey heer

Constructor Summary
CompositeComparator(java.util.Comparator[] cmp)
          Creates a new CompositeComparator.
CompositeComparator(java.util.Comparator[] cmp, boolean reverse)
          Creates a new CompositeComparator.
CompositeComparator(int size)
          Creates an empty CompositeComparator with the given capacity.
CompositeComparator(int size, boolean reverse)
          Creates an empty CompositeComparator with the given capacity.
 
Method Summary
 void add(java.util.Comparator c)
          Adds an additional comparator to this composite.
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 boolean remove(java.util.Comparator c)
          Removes a comparator from this composite.
 
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

CompositeComparator

public CompositeComparator(int size)
Creates an empty CompositeComparator with the given capacity.

Parameters:
size - the starting capacity of this comparator

CompositeComparator

public CompositeComparator(int size,
                           boolean reverse)
Creates an empty CompositeComparator with the given capacity.

Parameters:
size - the starting capacity of this comparator
reverse - when true, reverses the sort order of the included comparators, when false, objects are sorted as usual

CompositeComparator

public CompositeComparator(java.util.Comparator[] cmp)
Creates a new CompositeComparator.

Parameters:
cmp - the constituent comparators of this composite

CompositeComparator

public CompositeComparator(java.util.Comparator[] cmp,
                           boolean reverse)
Creates a new CompositeComparator.

Parameters:
cmp - the constituent comparators of this composite
reverse - when true, reverses the sort order of the included comparators, when false, objects are sorted as usual
Method Detail

add

public void add(java.util.Comparator c)
Adds an additional comparator to this composite.

Parameters:
c - the Comparator to add

remove

public boolean remove(java.util.Comparator c)
Removes a comparator from this composite.

Parameters:
c - the Comparator to remove
Returns:
true if the comparator was successfully removed, false otherwise

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
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