
net.sf.jagg.msd.DoubleDiscriminator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jagg-core Show documentation
Show all versions of jagg-core Show documentation
jAgg is a Java 5.0 API that supports “group by” operations on Lists of Java objects: aggregate operations such as count, sum, max, min, avg, and many more. It also allows custom aggregate operations.
The newest version!
package net.sf.jagg.msd;
/**
* A DoubleDiscriminator
discriminates Lists
of
* Doubles
.
*
* @author Randy Gettman
* @since 0.5.0
*/
public class DoubleDiscriminator extends NumberDiscriminator
{
/**
* Returns a portion extractor appropriate for doubles
.
* @param e An Extractor
that returns appropriate labels.
* @return An appropriate PortionExtractor
.
*/
protected PortionExtractor getPortionExtractor(Extractor e)
{
return new PortionExtractor(e) {
/**
* The label is the specific portion of the element, cast as an
* integer.
* @param element The element.
* @return The specific portion of the element, cast as an integer.
*/
public int getLabel(E element)
{
return (int) (Double.doubleToLongBits(myExtractor.getLabel(element)) >> (myIndex * PORTION_BITS)) & PORTION_MASK;
}
/**
* Complete after 4 portions.
* @param element The element.
* @return true
if the index is at least 4,
* false
otherwise.
*/
public boolean isComplete(E element)
{
return myExtractor.isComplete(element) || myIndex >= 4;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy