1
>
/*---------------------------------------------------------------------------------------------
prefixSumComputer.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { arrayInsert } from '../../../base/common/arrays.js';
7
>
import { toUint32 } from '../../../base/common/uint.js';
8
>
9
>
export class PrefixSumComputer {
10
>
11
>
/**
12
>
* values[i] is the value at index i
13
>
*/
14
>
private values: Uint32Array;
15
>
16
>
/**
17
>
* prefixSum[i] = SUM(heights[j]), 0 <= j <= i
18
>
*/
19
>
private prefixSum: Uint32Array;
20
>
21
>
/**
22
>
* prefixSum[i], 0 <= i <= prefixSumValidIndex can be trusted
23
>
*/
24
>
private readonly prefixSumValidIndex: Int32Array;
25
>
26
>
constructor(values: Uint32Array) {
27
this.values = values;
28
this.prefixSum = new Uint32Array(values.length);