當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript uint.toUint32Array函數代碼示例

本文整理匯總了TypeScript中vs/editor/common/core/uint.toUint32Array函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript toUint32Array函數的具體用法?TypeScript toUint32Array怎麽用?TypeScript toUint32Array使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了toUint32Array函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createLineMapping


//.........這裏部分代碼省略.........
				}
			}

			let charColumnSize = 1;
			if (strings.isFullWidthCharacter(charCode)) {
				charColumnSize = columnsForFullWidthChar;
			}

			// Advance visibleColumn with character at `i`
			visibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(visibleColumn, tabSize, charCodeIsTab, charColumnSize);

			if (visibleColumn > breakingColumn && i !== 0) {
				// We need to break at least before character at `i`:
				//  - break before niceBreakLastOffset if it exists (and re-establish a correct visibleColumn by using niceBreakVisibleColumn + charAt(i))
				//  - otherwise, break before obtrusiveBreakLastOffset if it exists (and re-establish a correct visibleColumn by using obtrusiveBreakVisibleColumn + charAt(i))
				//  - otherwise, break before i (and re-establish a correct visibleColumn by charAt(i))

				let breakBeforeOffset: number;
				let restoreVisibleColumnFrom: number;

				if (niceBreakOffset !== -1 && niceBreakVisibleColumn <= breakingColumn) {

					// We will break before `niceBreakLastOffset`
					breakBeforeOffset = niceBreakOffset;
					restoreVisibleColumnFrom = niceBreakVisibleColumn;

				} else if (obtrusiveBreakOffset !== -1 && obtrusiveBreakVisibleColumn <= breakingColumn) {

					// We will break before `obtrusiveBreakLastOffset`
					breakBeforeOffset = obtrusiveBreakOffset;
					restoreVisibleColumnFrom = obtrusiveBreakVisibleColumn;

				} else {

					// We will break before `i`
					breakBeforeOffset = i;
					restoreVisibleColumnFrom = wrappedTextIndentVisibleColumn;

				}

				// Break before character at `breakBeforeOffset`
				breakingLengths[breakingLengthsIndex++] = breakBeforeOffset - lastBreakingOffset;
				lastBreakingOffset = breakBeforeOffset;

				// Re-establish visibleColumn by taking character at `i` into account
				visibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(restoreVisibleColumnFrom, tabSize, charCodeIsTab, charColumnSize);

				// Reset markers
				niceBreakOffset = -1;
				niceBreakVisibleColumn = 0;
				obtrusiveBreakOffset = -1;
				obtrusiveBreakVisibleColumn = 0;
			}

			// At this point, there is a certainty that the character at `i` fits on the current line

			if (niceBreakOffset !== -1) {
				// Advance niceBreakVisibleColumn
				niceBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(niceBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
			}
			if (obtrusiveBreakOffset !== -1) {
				// Advance obtrusiveBreakVisibleColumn
				obtrusiveBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(obtrusiveBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
			}

			if (charCodeClass === CharacterClass.BREAK_AFTER && (hardWrappingIndent === WrappingIndent.None || i >= firstNonWhitespaceIndex)) {
				// This is a character that indicates that a break should happen after it
				niceBreakOffset = i + 1;
				niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
			}

			// CJK breaking : after break
			if (charCodeClass === CharacterClass.BREAK_IDEOGRAPHIC && i < len - 1) {
				let nextCode = lineText.charCodeAt(i + 1);
				let nextClass = classifier.get(nextCode);
				if (nextClass !== CharacterClass.BREAK_AFTER) { // Kinsoku Shori: Don't break before a trailing character, like a period
					niceBreakOffset = i + 1;
					niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
				}
			}

			if (charCodeClass === CharacterClass.BREAK_OBTRUSIVE) {
				// This is an obtrusive character that indicates that a break should happen after it
				obtrusiveBreakOffset = i + 1;
				obtrusiveBreakVisibleColumn = wrappedTextIndentVisibleColumn;
			}
		}

		if (breakingLengthsIndex === 0) {
			return null;
		}

		// Add last segment
		breakingLengths[breakingLengthsIndex++] = len - lastBreakingOffset;

		return new CharacterHardWrappingLineMapping(
			new PrefixSumComputer(toUint32Array(breakingLengths)),
			wrappedTextIndent
		);
	}
開發者ID:Chan-PH,項目名稱:vscode,代碼行數:101,代碼來源:characterHardWrappingLineMapper.ts

示例2: createLineMapping

function createLineMapping(breakingLengths: number[], wrappedLinesPrefix: string): ILineMapping {
	return new CharacterHardWrappingLineMapping(
		new PrefixSumComputer(toUint32Array(breakingLengths)),
		wrappedLinesPrefix
	);
}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:6,代碼來源:splitLinesCollection.test.ts

示例3: 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);
//.........這裏部分代碼省略.........
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:101,代碼來源:prefixSumComputer.test.ts


注:本文中的vs/editor/common/core/uint.toUint32Array函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。