本文整理汇总了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);
});
示例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);
}