com.aliasi.util
Class ReversibleComparator<E>

java.lang.Object
  extended by com.aliasi.util.FilterComparator<E>
      extended by com.aliasi.util.ReversibleComparator<E>
Type Parameters:
E - the type of objects being compared
All Implemented Interfaces:
Comparator<E>

Deprecated. Use Collections.reverseOrder(Comparator).

@Deprecated
public class ReversibleComparator<E>
extends FilterComparator<E>

Provides a filtering comparator that supports inverting the order of the comparison. A reversible comparator is constructed from a specified comparator as a filter comparator. The ordering will start out the same as the provided comparator. Whenever the toggleSortOrder() method is called, the order of comparison will be inverted. Calls to setOriginalSortOrder() set the ordering to be that of the contained comparator, whereas setReverseSortOrder() sets the ordering to be the inverse of that provided by the contained comparator.

To provide concurrent access to reversible comparators, they must be concurrent-read/single-write locked, where the methods toggleSortOrder(), setOriginalSortOrder(), and setReverseSortOrder() are writers, whereas the methods compare(Object,Object) is a reader. Exclusive locking on all methods suffices for safety.

Since:
LingPipe1.0
Version:
3.0
Author:
Bob Carpenter

Field Summary
 
Fields inherited from class com.aliasi.util.FilterComparator
mComparator
 
Constructor Summary
ReversibleComparator(Comparator<? super E> comparator)
          Deprecated. Construct a reversible comparator from the specified comparator.
 
Method Summary
 int compare(E x1, E x2)
          Deprecated. Return the result of comparing the specified objects using the contained comparator or its inverse.
 void setOriginalSortOrder()
          Deprecated. Resets this comparator to use the same ordering as the contained comparator provided at construction time.
 void setReverseSortOrder()
          Deprecated. Sets this comparator to use an ordering that is the inverse of that provided at construction time.
 void toggleSortOrder()
          Deprecated. Toggle the ordering on this comparator to be the inverse of its former ordering.
 
Methods inherited from class com.aliasi.util.FilterComparator
getFilteredComparator
 
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

ReversibleComparator

public ReversibleComparator(Comparator<? super E> comparator)
Deprecated. 
Construct a reversible comparator from the specified comparator. The initial ordering will be the same as the specified comparator.

Parameters:
comparator - The contained comparator in the reversible comparator being constructed.
Method Detail

compare

public int compare(E x1,
                   E x2)
Deprecated. 
Return the result of comparing the specified objects using the contained comparator or its inverse. Which ordering is specified by calls to toggleSortOrder(), setReverseSortOrder(), and setOriginalSortOrder().

Specified by:
compare in interface Comparator<E>
Overrides:
compare in class FilterComparator<E>
Parameters:
x1 - First object to compare.
x2 - Second object to compare.
Returns:
A positive integer if the first object is greater than the second, a negative integer if the second is greater than the first, and zero if they are the same.

toggleSortOrder

public void toggleSortOrder()
Deprecated. 
Toggle the ordering on this comparator to be the inverse of its former ordering.


setOriginalSortOrder

public void setOriginalSortOrder()
Deprecated. 
Resets this comparator to use the same ordering as the contained comparator provided at construction time.


setReverseSortOrder

public void setReverseSortOrder()
Deprecated. 
Sets this comparator to use an ordering that is the inverse of that provided at construction time.