当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript map.BoundedLinkedMap类代码示例

本文整理汇总了TypeScript中vs/base/common/map.BoundedLinkedMap的典型用法代码示例。如果您正苦于以下问题:TypeScript BoundedLinkedMap类的具体用法?TypeScript BoundedLinkedMap怎么用?TypeScript BoundedLinkedMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BoundedLinkedMap类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('BoundedLinkedMap - bounded with ratio', function () {
		const map = new BoundedLinkedMap<number>(6, 0.5);

		assert.equal(0, map.size);

		map.set('1', 1);
		map.set('2', 2);
		map.set('3', 3);
		map.set('4', 4);
		map.set('5', 5);
		map.set('6', 6);

		assert.equal(6, map.size);

		map.set('7', 7);

		assert.equal(3, map.size);
		assert.ok(!map.has('1'));
		assert.ok(!map.has('2'));
		assert.ok(!map.has('3'));
		assert.ok(!map.has('4'));
		assert.equal(map.get('5'), 5);
		assert.equal(map.get('6'), 6);
		assert.equal(map.get('7'), 7);

		map.set('8', 8);
		map.set('9', 9);
		map.set('10', 10);

		assert.equal(6, map.size);
		assert.equal(map.get('5'), 5);
		assert.equal(map.get('6'), 6);
		assert.equal(map.get('7'), 7);
		assert.equal(map.get('8'), 8);
		assert.equal(map.get('9'), 9);
		assert.equal(map.get('10'), 10);
	});
开发者ID:hungys,项目名称:vscode,代码行数:37,代码来源:map.test.ts

示例2: matchesFuzzy

export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching = false): IMatch[] {
	if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') {
		return null; // return early for invalid input
	}

	// Form RegExp for wildcard matches
	let regexp = fuzzyRegExpCache.get(word);
	if (!regexp) {
		regexp = new RegExp(strings.convertSimple2RegExpPattern(word), 'i');
		fuzzyRegExpCache.set(word, regexp);
	}

	// RegExp Filter
	let match: RegExpExecArray = regexp.exec(wordToMatchAgainst);
	if (match) {
		return [{ start: match.index, end: match.index + match[0].length }];
	}

	// Default Filter
	return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
}
开发者ID:fs814,项目名称:vscode,代码行数:21,代码来源:filters.ts


注:本文中的vs/base/common/map.BoundedLinkedMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。