本文整理匯總了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);
}