
net.sf.jagg.msd.Discriminator Maven / Gradle / Ivy
Show all versions of jagg-core Show documentation
package net.sf.jagg.msd;
import java.util.List;
/**
* A Discriminator
is able to distinguish elements of a given
* List
of objects of a certain type. It partitions the given
* list into a List
of equivalence classes. An
* equivalence class is represented by a List
of objects
* that compare equal, according to this Discriminator
.
*
* For example, in an unsorted list, one may have different values scattered
* randomly throughout the list:
* {100, 23, 5, 23, 10, 10, 5, 23, 6}
* The discrimination process returns a new List
of
* Lists
, each list containing an equivalence class. Each
* equivalence class list contains all values that compare equal to each other.
* They are not necessarily in sorted order. For example, integer
* discrimination of the above list yields the following result:
* {{100}, {6}, {23, 23, 23}, {5, 5}, {10, 10}}
* This algorithm is stable, meaning that values that do compare
* equal to each other remain in the same order as before, i.e. the first 5
* remains before the second 5 in the equivalence class list.
*
* @param The type being discriminated.
*
* @author Randy Gettman
* @since 0.5.0
*/
public interface Discriminator
{
/**
* Partitions the given List
of elements into another
* List
, in which all of the elements from the given list exist
* in the new list, and all elements that compare equal are adjacent to each
* other.
* @param elements A List
of elements.
* @param workspace The MsdWorkspace
used in the discrimination process.
* @return A List
of Lists
containing all
* equivalence classes. Each equivalence class list contains all values
* that compare equal to each other.
*/
public List> discriminate(List elements, MsdWorkspace workspace);
/**
* Partitions the given List
of elements into another
* List
, in which all of the elements from the given list exist
* in the new list, and all elements that compare equal are adjacent to each
* other, according to the given Extractor
.
* @param elements A List
of elements.
* @param extractor An Extractor
that gives labels for
* each element.
* @param workspace The MsdWorkspace
used in the discrimination process.
* @return A List
of Lists
containing all
* equivalence classes. Each equivalence class list contains all
* elements that compare equal to each other.
* @param The type of element that is being discriminated by the type
* <E>
*/
public List> discriminate(List elements, Extractor extractor, MsdWorkspace workspace);
}