Class AvgList

java.lang.Object
io.fi0x.javadatastructures.AvgList

public class AvgList extends Object
This list supports averaging methods for data. The way, data is returned can be modified.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor of this class.
    AvgList(List<Double> initialList)
    This constructor will copy the content of the provided list to a new one as its initial values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double value)
    Adds a value to the already existing list.
    get()
    This will return the averaged version of the original list.
    This will return the unmodified list that was provided to this class.
    void
    Forces a re-calculation of the returned list.
    remove(int index)
    This will remove a value at the indexed position in the list and return it.
    void
    setAdditionalAveragingValues(int additionalAveragingValues)
    This number defines, how many neighbouring values a value should be averaged with.
    void
    Sets the provided data s new base-data.
    void
    setLowCutoff(Double lowCutoff)
    All numbers that are equal or lower than this value, will be removed from the returned list.
    void
    setLowCutoffPercent(Double lowCutoffPercent)
    All numbers that are equal or lower than the lowest X percent of the highes value in the list, will be removed from the returned list.
    void
    setPreCalculate(boolean preCalculate)
    Weather or not the results should be calculated before retrieving them.
    void
    setTopCutoff(Double topCutoff)
    All numbers that are equal or higher than this value, will be removed from the returned list.
    void
    setTopCutoffPercent(Double topCutoffPercent)
    All numbers that are equal or higher than the top X percent of the highest value in the list, will be removed from the returned list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AvgList

      public AvgList()
      Default constructor of this class.
    • AvgList

      public AvgList(List<Double> initialList)
      This constructor will copy the content of the provided list to a new one as its initial values.
      Parameters:
      initialList - The original list with values to initialize this list.
  • Method Details

    • setData

      public void setData(List<Double> data)
      Sets the provided data s new base-data.
      Parameters:
      data - A list of values.
    • add

      public void add(double value)
      Adds a value to the already existing list.
      Parameters:
      value - The new value.
    • remove

      public Double remove(int index)
      This will remove a value at the indexed position in the list and return it.
      Parameters:
      index - The index of the value to be removed.
    • setPreCalculate

      public void setPreCalculate(boolean preCalculate)
      Weather or not the results should be calculated before retrieving them. When setting this to true, every modification of the data will result in a re-calculation of the returned list. The returned list will also be re-calculated, when the settings for this list change. Setting this to false, will cause the returned list to be calculated, when it's requested.
      Parameters:
      preCalculate - Weather to calculate on modification or on data reading. (Default is false)
    • setTopCutoff

      public void setTopCutoff(Double topCutoff)
      All numbers that are equal or higher than this value, will be removed from the returned list. Calling this method, while preCalculate is true, will result in an immediate re-calculation of the data. Setting this to null, will ignore this filter.
      Parameters:
      topCutoff - (Default is null)
    • setLowCutoff

      public void setLowCutoff(Double lowCutoff)
      All numbers that are equal or lower than this value, will be removed from the returned list. Calling this method, while preCalculate is true, will result in an immediate re-calculation of the data. Setting this to null, will ignore this filter.
      Parameters:
      lowCutoff - (Default is null)
    • setTopCutoffPercent

      public void setTopCutoffPercent(Double topCutoffPercent)
      All numbers that are equal or higher than the top X percent of the highest value in the list, will be removed from the returned list. Calling this method, while preCalculate is true, will result in an immediate re-calculation of the data. Setting this to null, will ignore this filter.
      Parameters:
      topCutoffPercent - (Default is null)
    • setLowCutoffPercent

      public void setLowCutoffPercent(Double lowCutoffPercent)
      All numbers that are equal or lower than the lowest X percent of the highes value in the list, will be removed from the returned list. Calling this method, while preCalculate is true, will result in an immediate re-calculation of the data. Setting this to null, will ignore this filter.
      Parameters:
      lowCutoffPercent - (Default is null)
    • setAdditionalAveragingValues

      public void setAdditionalAveragingValues(int additionalAveragingValues)
      This number defines, how many neighbouring values a value should be averaged with. When this is 1, it will be compared with its next and previous value and return the average of the 3 values instead of its original value. Calling this method, while preCalculate is true, will result in an immediate re-calculation of the data. Setting this to 0 will result in no averaging between neighbouring values.
      Parameters:
      additionalAveragingValues - (Default is 0)
    • getOriginalList

      public List<Double> getOriginalList()
      This will return the unmodified list that was provided to this class. (Added values are also included)
      Returns:
      The original list.
    • get

      public List<Double> get()
      This will return the averaged version of the original list. If all settings are set to their default values, this list and the original one are identical.
      Returns:
      A new list with averaged values.
    • reCalculate

      public void reCalculate()
      Forces a re-calculation of the returned list. This will only re-calculate the results, if a change was made to the settings or values of this list since the last re-calculation.