本文整理匯總了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);
//.........這裏部分代碼省略.........