edu.mit.jmwe.util
Class CompositeComparator<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<Comparator<T>>
edu.mit.jmwe.util.CompositeComparator<T>
- All Implemented Interfaces:
- Iterable<Comparator<T>>, Collection<Comparator<T>>, Comparator<T>, List<Comparator<T>>
public class CompositeComparator<T>
- extends AbstractList<Comparator<T>>
- implements Comparator<T>, List<Comparator<T>>
A comparator constructed out of multiple comparators.
- Since:
- jMWE 1.0.0
- Version:
- $Id: CompositeComparator.java 610 2011-05-06 20:05:20Z markaf $
- Author:
- M.A. Finlayson
Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
Methods inherited from interface java.util.List |
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray |
CompositeComparator
public CompositeComparator(Comparator<T> one,
Comparator<T> two)
- Constructs a composite comparator from two of comparators. The array of
comparators should be ordered by descending preference. The most
preferred comparator should be first, the second-most-preferred second,
etc. The comparators may not be
null
- Throws:
NullPointerException
- if any specified comparator null
.- Since:
- jMWE 1.0.0
CompositeComparator
public CompositeComparator(Comparator<T> one,
Comparator<T> two,
Comparator<T> three)
- Constructs a composite comparator from three of comparators. The array of
comparators should be ordered by descending preference. The most
preferred comparator should be first, the second-most-preferred second,
etc. The comparators may not be
null
- Throws:
NullPointerException
- if any specified comparator null
.- Since:
- jMWE 1.0.0
CompositeComparator
public CompositeComparator(Comparator<T>... cs)
- Constructs a composite comparator from an array of comparators. The array
of comparators should be ordered by descending preference. The most
preferred comparator should be first, the second-most-preferred second,
etc.
- Parameters:
cs
- the array of comparators in order of descending preference.
May not be null
, nor contain null
.
- Throws:
NullPointerException
- if the specified array is null
or if any of its
elements are null
.- Since:
- jMWE 1.0.0
CompositeComparator
public CompositeComparator(List<? extends Comparator<T>> cs)
- Constructs a composite comparator from an array of comparators. The array
of comparators should be ordered by descending preference. The most
preferred comparator should be first, the second-most-preferred second,
etc.
- Parameters:
cs
- the list of comparators in order of descending preference.
May not be null
, nor contain null
.
- Throws:
NullPointerException
- if the specified array is null
or if any of its
elements are null
.- Since:
- jMWE 1.0.0
compare
public int compare(T one,
T two)
- Specified by:
compare
in interface Comparator<T>
get
public Comparator<T> get(int index)
- Specified by:
get
in interface List<Comparator<T>>
- Specified by:
get
in class AbstractList<Comparator<T>>
size
public int size()
- Specified by:
size
in interface Collection<Comparator<T>>
- Specified by:
size
in interface List<Comparator<T>>
- Specified by:
size
in class AbstractCollection<Comparator<T>>
Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.