edu.mit.jmwe.util
Class ListComparator<T>
java.lang.Object
edu.mit.jmwe.util.AbstractIndexComparator<T,T>
edu.mit.jmwe.util.ListComparator<T>
- Type Parameters:
T
- the token type
- All Implemented Interfaces:
- Comparator<T>
public class ListComparator<T>
- extends AbstractIndexComparator<T,T>
Compares two elements from a list based on their order of appearance in the
list. Returns a negative integer, zero, or a positive integer if the first
argument is appears earlier than, is equal to, or after the second.
- Since:
- jMWE 1.0.0
- Version:
- $Id: ListComparator.java 558 2011-05-05 19:23:28Z markaf $
- Author:
- N. Kulkarni, M.A. Finlayson
Constructor Summary |
ListComparator(List<T> list)
Constructs the comparator from the given list of objects by mapping each
object in the list to its index in the list. |
ListComparator(Map<T,Integer> indexMap)
Constructs the comparator from the given index map of each object in a
list to its index in the list. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ListComparator
public ListComparator(List<T> list)
- Constructs the comparator from the given list of objects by mapping each
object in the list to its index in the list.
- Parameters:
list
- the list of objects used to construct this comparator. May not
be null
.
- Throws:
NullPointerException
- if the given list is null
- Since:
- jMWE 1.0.0
ListComparator
public ListComparator(Map<T,Integer> indexMap)
- Constructs the comparator from the given index map of each object in a
list to its index in the list.
- Parameters:
indexMap
- map of each object in a list to its index in the list. May not
be null
.
- Throws:
NullPointerException
- if the specified map is null
- Since:
- jMWE 1.0.0
compare
public int compare(T arg0,
T arg1)
Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.