This library contains functions to manage Partial Differences data
structure. Partial Differences is an array of value differences over time.
For example: assuming an array [3, 6, 3, 1, 2], partial differences can
represent this array as [_, 3, -3, -2, 1].
This data structure allows adding values on an open interval with O(1)
complexity.
For example: add +5 to [3, 6, 3, 1, 2] starting from the second element (3),
instead of performing [3, 6, 3+5, 1+5, 2+5] partial differences allows
performing [_, 3, -3+5, -2, 1]. The original array can be restored by
adding values from partial differences.
Functions
-
addToSequence(sequence, diff, month)
-
subtractFromSequence(sequence, diff, month)
-
getAndUpdateValueInSequence(sequence, month)
-
reduceSequence(sequence, reducingCoefficient, month)
-
addToValue(sequence, diff, month)
-
subtractFromValue(sequence, diff, month)
-
getAndUpdateValue(sequence, month)
-
reduceValue(sequence, amount, month)
-
reduceValueByCoefficient(sequence, reducingCoefficient, month)
-
reduceValueByCoefficientAndUpdateSum(sequence, sumSequence, reducingCoefficient, month)
-
reduceValueByCoefficientAndUpdateSumIfNeeded(sequence, sumSequence, reducingCoefficient, month, hasSumSequence)
-
getValueInSequence(sequence, month)
-
getValuesInSequence(sequence)
-
getValue(sequence, month)
-
getValues(sequence)