本文整理汇总了TypeScript中vs/editor/common/viewModel/prefixSumComputer.PrefixSumComputer.getTotalValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PrefixSumComputer.getTotalValue方法的具体用法?TypeScript PrefixSumComputer.getTotalValue怎么用?TypeScript PrefixSumComputer.getTotalValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/viewModel/prefixSumComputer.PrefixSumComputer
的用法示例。
在下文中一共展示了PrefixSumComputer.getTotalValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getOutputLineCount
public getOutputLineCount(): number {
this._ensureValidState();
return this.prefixSumComputer.getTotalValue();
}
示例2: test
test('PrefixSumComputer', () => {
var indexOfResult:IPrefixSumIndexOfResult = {
index: 0,
remainder: 0
};
var psc = new PrefixSumComputer([1, 1, 2, 1, 3]);
assert.equal(psc.getTotalValue(), 8);
assert.equal(psc.getAccumulatedValue(-1), 0);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 2);
assert.equal(psc.getAccumulatedValue(2), 4);
assert.equal(psc.getAccumulatedValue(3), 5);
assert.equal(psc.getAccumulatedValue(4), 8);
psc.getIndexOf(0, indexOfResult);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(1, indexOfResult);
assert.equal(indexOfResult.index, 1);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(2, indexOfResult);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(3, indexOfResult);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 1);
psc.getIndexOf(4, indexOfResult);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(5, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(6, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 1);
psc.getIndexOf(7, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 2);
psc.getIndexOf(8, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 3);
// [1, 2, 2, 1, 3]
psc.changeValue(1, 2);
assert.equal(psc.getTotalValue(), 9);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 3);
assert.equal(psc.getAccumulatedValue(2), 5);
assert.equal(psc.getAccumulatedValue(3), 6);
assert.equal(psc.getAccumulatedValue(4), 9);
// [1, 0, 2, 1, 3]
psc.changeValue(1, 0);
assert.equal(psc.getTotalValue(), 7);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 1);
assert.equal(psc.getAccumulatedValue(2), 3);
assert.equal(psc.getAccumulatedValue(3), 4);
assert.equal(psc.getAccumulatedValue(4), 7);
psc.getIndexOf(0, indexOfResult);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(1, indexOfResult);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(2, indexOfResult);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 1);
psc.getIndexOf(3, indexOfResult);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(4, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(5, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 1);
psc.getIndexOf(6, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 2);
psc.getIndexOf(7, indexOfResult);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 3);
// [1, 0, 0, 1, 3]
psc.changeValue(2, 0);
assert.equal(psc.getTotalValue(), 5);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 1);
assert.equal(psc.getAccumulatedValue(2), 1);
assert.equal(psc.getAccumulatedValue(3), 2);
assert.equal(psc.getAccumulatedValue(4), 5);
psc.getIndexOf(0, indexOfResult);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(1, indexOfResult);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
psc.getIndexOf(2, indexOfResult);
assert.equal(indexOfResult.index, 4);
//.........这里部分代码省略.........
示例3: getLength
public getLength(): number {
return this._lineStarts.getTotalValue();
}
示例4: test
test('PrefixSumComputer', () => {
let indexOfResult: PrefixSumIndexOfResult;
let psc = new PrefixSumComputer(toUint32Array([1, 1, 2, 1, 3]));
assert.equal(psc.getTotalValue(), 8);
assert.equal(psc.getAccumulatedValue(-1), 0);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 2);
assert.equal(psc.getAccumulatedValue(2), 4);
assert.equal(psc.getAccumulatedValue(3), 5);
assert.equal(psc.getAccumulatedValue(4), 8);
indexOfResult = psc.getIndexOf(0);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(1);
assert.equal(indexOfResult.index, 1);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(2);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(3);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(4);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(5);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(6);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(7);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 2);
indexOfResult = psc.getIndexOf(8);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 3);
// [1, 2, 2, 1, 3]
psc.changeValue(1, 2);
assert.equal(psc.getTotalValue(), 9);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 3);
assert.equal(psc.getAccumulatedValue(2), 5);
assert.equal(psc.getAccumulatedValue(3), 6);
assert.equal(psc.getAccumulatedValue(4), 9);
// [1, 0, 2, 1, 3]
psc.changeValue(1, 0);
assert.equal(psc.getTotalValue(), 7);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 1);
assert.equal(psc.getAccumulatedValue(2), 3);
assert.equal(psc.getAccumulatedValue(3), 4);
assert.equal(psc.getAccumulatedValue(4), 7);
indexOfResult = psc.getIndexOf(0);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(1);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(2);
assert.equal(indexOfResult.index, 2);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(3);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(4);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(5);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 1);
indexOfResult = psc.getIndexOf(6);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 2);
indexOfResult = psc.getIndexOf(7);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 3);
// [1, 0, 0, 1, 3]
psc.changeValue(2, 0);
assert.equal(psc.getTotalValue(), 5);
assert.equal(psc.getAccumulatedValue(0), 1);
assert.equal(psc.getAccumulatedValue(1), 1);
assert.equal(psc.getAccumulatedValue(2), 1);
assert.equal(psc.getAccumulatedValue(3), 2);
assert.equal(psc.getAccumulatedValue(4), 5);
indexOfResult = psc.getIndexOf(0);
assert.equal(indexOfResult.index, 0);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(1);
assert.equal(indexOfResult.index, 3);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(2);
assert.equal(indexOfResult.index, 4);
assert.equal(indexOfResult.remainder, 0);
indexOfResult = psc.getIndexOf(3);
assert.equal(indexOfResult.index, 4);
//.........这里部分代码省略.........