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


TypeScript WhitespaceComputer.findInsertionIndex方法代碼示例

本文整理匯總了TypeScript中vs/editor/common/viewLayout/whitespaceComputer.WhitespaceComputer.findInsertionIndex方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript WhitespaceComputer.findInsertionIndex方法的具體用法?TypeScript WhitespaceComputer.findInsertionIndex怎麽用?TypeScript WhitespaceComputer.findInsertionIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/editor/common/viewLayout/whitespaceComputer.WhitespaceComputer的用法示例。


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

示例1: test

	test('WhitespaceComputer findInsertionIndex', () => {

		var makeArray = (size: number, fillValue: number) => {
			var r: number[] = [];
			for (var i = 0; i < size; i++) {
				r[i] = fillValue;
			}
			return r;
		};

		var arr: number[];
		var ordinals: number[];

		arr = [];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 0);

		arr = [1];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);

		arr = [1, 3];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);

		arr = [1, 3, 5];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);

		arr = [1, 3, 5];
		ordinals = makeArray(arr.length, 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);

		arr = [1, 3, 5, 7];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);

		arr = [1, 3, 5, 7, 9];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);

		arr = [1, 3, 5, 7, 9, 11];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 3, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 4, ordinals, 0), 2);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 5, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 6, ordinals, 0), 3);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 7, ordinals, 0), 4);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 8, ordinals, 0), 4);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 9, ordinals, 0), 5);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 10, ordinals, 0), 5);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 11, ordinals, 0), 6);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 12, ordinals, 0), 6);

		arr = [1, 3, 5, 7, 9, 11, 13];
		ordinals = makeArray(arr.length, 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 0, ordinals, 0), 0);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 1, ordinals, 0), 1);
		assert.equal(WhitespaceComputer.findInsertionIndex(arr, 2, ordinals, 0), 1);
//.........這裏部分代碼省略.........
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:101,代碼來源:whitespaceComputer.test.ts


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