org.planx.msd.number
Class IntegerDiscriminator

java.lang.Object
  extended by org.planx.msd.util.AbstractDiscriminator<T>
      extended by org.planx.msd.number.NumberDiscriminator<Integer>
          extended by org.planx.msd.number.IntegerDiscriminator
All Implemented Interfaces:
Discriminator<Integer>

public class IntegerDiscriminator
extends NumberDiscriminator<Integer>

A Discriminator capable of discriminating a multiset of Integer objects.

Author:
Thomas Ambus

Nested Class Summary
 
Nested classes/interfaces inherited from class org.planx.msd.number.NumberDiscriminator
NumberDiscriminator.ChunkExtractor<U>
 
Field Summary
 
Fields inherited from class org.planx.msd.number.NumberDiscriminator
CHUNK_BITSIZE, CHUNK_MASK, memory
 
Constructor Summary
IntegerDiscriminator(Memory memory)
           
 
Method Summary
protected  int bitsize()
          Returns the total bitsize of the specific type of number.
protected
<U> NumberDiscriminator.ChunkExtractor<U>
chunkExtractor(Extractor<U,? extends Integer,?> e)
          returns a ChunkExtractor for the specific type of number.
<U,S> Collection<List<S>>
discriminate(List<? extends U> values, Extractor<U,? extends Integer,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.
<U,S> Collection<List<S>>
discriminate(List<? extends U> values, IntExtractor<U,S> e)
          Optimized integer discrimination, relying on an array of size 2^16, performing two passes.
 
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

IntegerDiscriminator

public IntegerDiscriminator(Memory memory)
Method Detail

discriminate

public <U,S> Collection<List<S>> discriminate(List<? extends U> values,
                                              Extractor<U,? extends Integer,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<Integer>
Overrides:
discriminate in class NumberDiscriminator<Integer>

discriminate

public <U,S> Collection<List<S>> discriminate(List<? extends U> values,
                                              IntExtractor<U,S> e)
Optimized integer discrimination, relying on an array of size 2^16, performing two passes. Furthermore, it is optimistic in the sense that it attempts to use only one pass, i.e. hopes that all ints are 16 bit, forming the result directly from the first pass. If an int larger than 16 bit is encountered it breaks and restarts, performing two passes.


bitsize

protected int bitsize()
Description copied from class: NumberDiscriminator
Returns the total bitsize of the specific type of number.

Specified by:
bitsize in class NumberDiscriminator<Integer>

chunkExtractor

protected <U> NumberDiscriminator.ChunkExtractor<U> chunkExtractor(Extractor<U,? extends Integer,?> e)
Description copied from class: NumberDiscriminator
returns a ChunkExtractor for the specific type of number.

Specified by:
chunkExtractor in class NumberDiscriminator<Integer>


Copyright © 2010. All Rights Reserved.