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 sumnumber The cumulated frequency
Returns:
- Type
- number
-
read(count)
-
Read the sum of the first
countfrequenciesParameters:
Name Type Description countnumber The count of frequencies to accumulate
Returns:
- Type
- number
-
readSingle(idx)
-
Read a single frequency
Parameters:
Name Type Description idxnumber 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 idxnumber The 0 based index for the frequency
deltanumber 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 sumnumber The cumulated frequency
Returns:
- Type
- number
-
writeSingle(idx, freq)
-
Update a single frequency with a given value
Parameters:
Name Type Description idxnumber The 0 based index for the frequency
freqnumber The new frequency
Returns:
- Type
- undefined