Package io.fi0x.javadatastructures
Class AvgList
java.lang.Object
io.fi0x.javadatastructures.AvgList
This list supports averaging methods for data. The way, data is returned can be modified.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(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.voidForces 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.voidsetAdditionalAveragingValues(int additionalAveragingValues) This number defines, how many neighbouring values a value should be averaged with.voidSets the provided data s new base-data.voidsetLowCutoff(Double lowCutoff) All numbers that are equal or lower than this value, will be removed from the returned list.voidsetLowCutoffPercent(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.voidsetPreCalculate(boolean preCalculate) Weather or not the results should be calculated before retrieving them.voidsetTopCutoff(Double topCutoff) All numbers that are equal or higher than this value, will be removed from the returned list.voidsetTopCutoffPercent(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.
-
Constructor Details
-
AvgList
public AvgList()Default constructor of this class. -
AvgList
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
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
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
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
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
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
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
This will return the unmodified list that was provided to this class. (Added values are also included)- Returns:
- The original list.
-
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.
-