T - the type of the tokens that are indexedC - the type of the object being comparedpublic abstract class AbstractIndexComparator<T,C>
extends java.lang.Object
implements java.util.Comparator<C>
Comparator from a map of tokens in a
list to their positions in the list. Subclasses are comparators that compare
objects that consist of these tokens by using the tokens' indices.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<T,java.lang.Integer> |
indexMap |
| Constructor and Description |
|---|
AbstractIndexComparator(java.util.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.
|
AbstractIndexComparator(java.util.Map<T,java.lang.Integer> indexMap)
Constructs the comparator from the given index map of each object in a
list to its index in the list.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Map<T,java.lang.Integer> |
createIndexMap(java.util.List<T> list)
Returns a map of each object in the list mapped to its index in the list.
|
java.util.Map<T,java.lang.Integer> |
getIndexMap()
Returns the index map on which this comparator is based.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongprotected final java.util.Map<T,java.lang.Integer> indexMap
public AbstractIndexComparator(java.util.List<T> list)
list - the list of objects used to construct this comparator. May not
be null.java.lang.NullPointerException - if the given list is null.public AbstractIndexComparator(java.util.Map<T,java.lang.Integer> indexMap)
indexMap - map of each object in a list to its index in the list. May not
be null.java.lang.NullPointerException - if the specified map is nullpublic java.util.Map<T,java.lang.Integer> getIndexMap()
null index map on which this comparator is
based.public static <T> java.util.Map<T,java.lang.Integer> createIndexMap(java.util.List<T> list)
T - the type of objects in the sentencelist - a non-null listjava.lang.NullPointerException - if the given list is null.Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.