Class LTThreeBuckets

java.lang.Object
com.ggalmazor.ltdownsampling.LTThreeBuckets

public final class LTThreeBuckets extends Object
The LTThreeBuckets class is the main entry point to this library.

None of the methods in this class will mutate input lists or their elements.

  • Method Details

    • sorted

      public static <T extends Point> List<T> sorted(List<T> input, int desiredBuckets)
      Returns a downsampled version of the provided input list.

      Notes:

      • The input list must be sorted.
      • This method doesn't mutate the input list or any of its elements.

      The output list will have desiredBuckets + 2 elements: one per bucket plus the first and last points of the original series.

      Type Parameters:
      T - the type of the Point elements in the input list
      Parameters:
      input - the input list of Point points to downsample
      desiredBuckets - the desired number of buckets for the downsampled output list
      Returns:
      the downsampled output list
    • sorted

      public static <T extends Point> List<T> sorted(List<T> input, int inputSize, int desiredBuckets)
      Returns a downsampled version of the provided input list.

      Notes:

      • The input list must be sorted.
      • This method doesn't mutate the input list or any of its elements.

      The output list will have desiredBuckets + 2 elements: one per bucket plus the first and last points of the original series.

      When the input contains DoublePoint instances, an optimised struct-of-arrays path is used: x and y coordinates are extracted into contiguous double[] arrays before the selection loop, eliminating per-point pointer chasing in the hot path.

      When desiredBuckets exceeds 512, the triangle-selection loop runs in parallel using the common ForkJoinPool.

      Type Parameters:
      T - the type of the Point elements in the input list
      Parameters:
      input - the input list of Point points to downsample
      inputSize - the size of the input list
      desiredBuckets - the desired number of buckets for the downsampled output list
      Returns:
      the downsampled output list