|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.util.FilterComparator<E>
com.aliasi.util.ReversibleComparator<E>
public class ReversibleComparator<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.
| Field Summary |
|---|
| Fields inherited from class com.aliasi.util.FilterComparator |
|---|
mComparator |
| Constructor Summary | |
|---|---|
ReversibleComparator(Comparator<? super E> comparator)
Construct a reversible comparator from the specified comparator. |
|
| Method Summary | |
|---|---|
int |
compare(E x1,
E x2)
Return the result of comparing the specified objects using the contained comparator or its inverse. |
void |
setOriginalSortOrder()
Resets this comparator to use the same ordering as the contained comparator provided at construction time. |
void |
setReverseSortOrder()
Sets this comparator to use an ordering that is the inverse of that provided at construction time. |
void |
toggleSortOrder()
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 |
|---|
public ReversibleComparator(Comparator<? super E> comparator)
comparator - The contained comparator in the reversible
comparator being constructed.| Method Detail |
|---|
public int compare(E x1,
E x2)
toggleSortOrder(), setReverseSortOrder(), and setOriginalSortOrder().
compare in interface Comparator<E>compare in class FilterComparator<E>x1 - First object to compare.x2 - Second object to compare.
public void toggleSortOrder()
public void setOriginalSortOrder()
public void setReverseSortOrder()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||