new BinaryIndexedTree(options)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Members
-
defaultFrequency :number
-
The default initial frequency
Type:
- number
-
maxVal :number
-
The maximum value which will have non-zero frequency
Type:
- number
Methods
-
lowerBound(sum)
-
Read the lower-bound with the given cumulated frequency REQUIRE ALL FREQUENCIES TO BE NON-NEGATIVE
Parameters:
Name Type Description sum
number The cumulated frequency
Returns:
- Type
- number
-
read(count)
-
Read the sum of the first
count
frequenciesParameters:
Name Type Description count
number The count of frequencies to accumulate
Returns:
- Type
- number
-
readSingle(idx)
-
Read a single frequency
Parameters:
Name Type Description idx
number The 0 based index for the frequency
Returns:
- Type
- number
-
update(idx, delta)
-
Update a single frequency with a delta value
Parameters:
Name Type Description idx
number The 0 based index for the frequency
delta
number The delta value of the freqency
Returns:
- Type
- undefined
-
upperBound(sum)
-
Read the upper-bound with the given cumulated frequency REQUIRE ALL FREQUENCIES TO BE NON-NEGATIVE
Parameters:
Name Type Description sum
number The cumulated frequency
Returns:
- Type
- number
-
writeSingle(idx, freq)
-
Update a single frequency with a given value
Parameters:
Name Type Description idx
number The 0 based index for the frequency
freq
number The new frequency
Returns:
- Type
- undefined