org.planx.msd.list
Class ListDiscriminator<T>

java.lang.Object
  extended by org.planx.msd.util.AbstractDiscriminator<List<T>>
      extended by org.planx.msd.list.ListDiscriminator<T>
All Implemented Interfaces:
Discriminator<List<T>>

public class ListDiscriminator<T>
extends AbstractDiscriminator<List<T>>

A Discriminator capable of discriminating a multiset of Lists of objects. A Discriminator for the type contained within the lists must be provided in the constructor. This discriminator checks if all lists support random access, and uses a SizeRandomAccessListDiscriminator to perform discrimination. If some lists do not support random access, they are wrapped in IteratorLists that allow the algorithm to run in O(N) time by utilizing the order in which elements are examined.

Note that this implementation is not synchronized. If multiple threads access an instance of this class concurrently, it must be synchronized externally.

Author:
Thomas Ambus

Constructor Summary
ListDiscriminator(Discriminator<T> d, Memory memory)
          Creates a new ListDiscriminator able to discriminate a multiset of List objects.
 
Method Summary
<U,S> Collection<List<S>>
discriminate(List<? extends U> values, Extractor<U,? extends List<T>,S> e)
          Discriminates a List of values using an Extractor, and returns a Collection of Lists, each representing an equivalence class containing elements from values that are equivalent.
 
Methods inherited from class org.planx.msd.util.AbstractDiscriminator
discriminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListDiscriminator

public ListDiscriminator(Discriminator<T> d,
                         Memory memory)
Creates a new ListDiscriminator able to discriminate a multiset of List objects. Each List must contain objects of type T, where the argument discriminator d is able to discriminate objects of type T. The instance will reuse the memory of the specified Memory.

Method Detail

discriminate

public <U,S> Collection<List<S>> discriminate(List<? extends U> values,
                                              Extractor<U,? extends List<T>,S> e)
Description copied from interface: Discriminator
Discriminates a List of values using an Extractor, and returns a Collection of Lists, each representing an equivalence class containing elements from values that are equivalent. The Extractor performs the task of extracting two kinds of objects from the input values: The label which is the object equivalence is defined upon, and the value which is the object that will be returned. That is, the label determines which equivalence class the value goes into.

The Collection of Lists returned should be considered unmodifiable (though, in some cases they might actually be modifiable, but this behaviour should not be relied upon).

Specified by:
discriminate in interface Discriminator<List<T>>
Specified by:
discriminate in class AbstractDiscriminator<List<T>>


Copyright © 2010. All Rights Reserved.