All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.jagg.msd.LongDiscriminator Maven / Gradle / Ivy

Go to download

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 LongDiscriminator discriminates Lists of
 * Longs.
 *
 * @author Randy Gettman
 * @since 0.5.0
 */
public class LongDiscriminator extends NumberDiscriminator
{
   /**
    * Returns a portion extractor appropriate for longs.
    * @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) ((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