some renamed in Map land
This commit is contained in:
parent
f29f71d10b
commit
e9c80f0366
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import strings = require('vs/base/common/strings');
|
||||
import {LinkedMap} from 'vs/base/common/map';
|
||||
import {BoundedLinkedMap} from 'vs/base/common/map';
|
||||
|
||||
export interface IFilter {
|
||||
// Returns null if word doesn't match.
|
||||
|
@ -299,7 +299,7 @@ export enum SubstringMatching {
|
|||
|
||||
export const fuzzyContiguousFilter = or(matchesPrefix, matchesCamelCase, matchesContiguousSubString);
|
||||
const fuzzySeparateFilter = or(matchesPrefix, matchesCamelCase, matchesSubString);
|
||||
const fuzzyRegExpCache = new LinkedMap<RegExp>(10000); // bounded to 10000 elements
|
||||
const fuzzyRegExpCache = new BoundedLinkedMap<RegExp>(10000); // bounded to 10000 elements
|
||||
|
||||
export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching = false): IMatch[] {
|
||||
if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import strings = require('vs/base/common/strings');
|
||||
import paths = require('vs/base/common/paths');
|
||||
import {LinkedMap} from 'vs/base/common/map';
|
||||
import {BoundedLinkedMap} from 'vs/base/common/map';
|
||||
|
||||
export interface IExpression {
|
||||
[pattern: string]: boolean | SiblingClause | any;
|
||||
|
@ -222,7 +222,7 @@ interface IParsedPattern {
|
|||
trivia?: Trivia;
|
||||
}
|
||||
|
||||
const CACHE = new LinkedMap<IParsedPattern>(10000); // bounded to 10000 elements
|
||||
const CACHE = new BoundedLinkedMap<IParsedPattern>(10000); // bounded to 10000 elements
|
||||
|
||||
function parsePattern(pattern: string): IParsedPattern {
|
||||
if (!pattern) {
|
||||
|
|
|
@ -20,7 +20,7 @@ export interface Entry<K, T> {
|
|||
* A simple map to store value by a key object. Key can be any object that has toString() function to get
|
||||
* string value of the key.
|
||||
*/
|
||||
export class SimpleMap<K extends Key, T> {
|
||||
export class LinkedMap<K extends Key, T> {
|
||||
|
||||
protected map: { [key: string]: Entry<K, T> };
|
||||
protected _size: number;
|
||||
|
@ -114,7 +114,7 @@ export class SimpleMap<K extends Key, T> {
|
|||
* the cache will remove the entry that was last recently added. Or, if a ratio is provided below 1,
|
||||
* all elements will be removed until the ratio is full filled (e.g. 0.75 to remove 25% of old elements).
|
||||
*/
|
||||
export class LinkedMap<T> {
|
||||
export class BoundedLinkedMap<T> {
|
||||
protected map: { [key: string]: Entry<string, T> };
|
||||
private head: Entry<string, T>;
|
||||
private tail: Entry<string, T>;
|
||||
|
@ -252,7 +252,7 @@ export class LinkedMap<T> {
|
|||
* maximum number of elements in the cache, it helps to remove those
|
||||
* entries from the cache that are LRU.
|
||||
*/
|
||||
export class LRUCache<T> extends LinkedMap<T> {
|
||||
export class LRUCache<T> extends BoundedLinkedMap<T> {
|
||||
|
||||
constructor(limit: number) {
|
||||
super(limit);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {LinkedMap} from 'vs/base/common/map';
|
||||
import {BoundedLinkedMap} from 'vs/base/common/map';
|
||||
|
||||
/**
|
||||
* The empty string.
|
||||
|
@ -221,7 +221,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean {
|
|||
*/
|
||||
export let canNormalize = typeof ((<any>'').normalize) === 'function';
|
||||
const nonAsciiCharactersPattern = /[^\u0000-\u0080]/;
|
||||
const normalizedCache = new LinkedMap<string>(10000); // bounded to 10000 elements
|
||||
const normalizedCache = new BoundedLinkedMap<string>(10000); // bounded to 10000 elements
|
||||
export function normalizeNFC(str: string): string {
|
||||
if (!canNormalize || !str) {
|
||||
return str;
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import {LinkedMap, LRUCache} from 'vs/base/common/map';
|
||||
import {BoundedLinkedMap, LRUCache} from 'vs/base/common/map';
|
||||
import * as assert from 'assert';
|
||||
|
||||
suite('Map', () => {
|
||||
test('LinkedMap - basics', function () {
|
||||
const map = new LinkedMap<any>();
|
||||
test('BoundedLinkedMap - basics', function () {
|
||||
const map = new BoundedLinkedMap<any>();
|
||||
|
||||
assert.equal(map.size, 0);
|
||||
|
||||
|
@ -66,8 +66,8 @@ suite('Map', () => {
|
|||
assert.ok(!map.has('1'));
|
||||
});
|
||||
|
||||
test('LinkedMap - bounded', function () {
|
||||
const map = new LinkedMap<number>(5);
|
||||
test('BoundedLinkedMap - bounded', function () {
|
||||
const map = new BoundedLinkedMap<number>(5);
|
||||
|
||||
assert.equal(0, map.size);
|
||||
|
||||
|
@ -135,8 +135,8 @@ suite('Map', () => {
|
|||
assert.equal(map.get('14'), 14);
|
||||
});
|
||||
|
||||
test('LinkedMap - bounded with ratio', function () {
|
||||
const map = new LinkedMap<number>(6, 0.5);
|
||||
test('BoundedLinkedMap - bounded with ratio', function () {
|
||||
const map = new BoundedLinkedMap<number>(6, 0.5);
|
||||
|
||||
assert.equal(0, map.size);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import * as sinon from 'sinon';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { SimpleMap } from 'vs/base/common/map';
|
||||
import { LinkedMap } from 'vs/base/common/map';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
@ -34,12 +34,12 @@ interface IServiceMock<T> {
|
|||
|
||||
export class TestInstantiationService extends InstantiationService {
|
||||
|
||||
private _servciesMap: SimpleMap<ServiceIdentifier<any>, any>;
|
||||
private _servciesMap: LinkedMap<ServiceIdentifier<any>, any>;
|
||||
|
||||
constructor(private _serviceCollection: ServiceCollection = new ServiceCollection()) {
|
||||
super(_serviceCollection);
|
||||
|
||||
this._servciesMap= new SimpleMap<ServiceIdentifier<any>, any>();
|
||||
this._servciesMap= new LinkedMap<ServiceIdentifier<any>, any>();
|
||||
this._servciesMap.set(ITelemetryService, NullTelemetryService);
|
||||
this._servciesMap.set(IEventService, EventService);
|
||||
this._servciesMap.set(ISearchService, SearchService);
|
||||
|
|
|
@ -88,14 +88,14 @@ export class FilterOptions {
|
|||
|
||||
export class MarkersModel {
|
||||
|
||||
private markersByResource: Map.SimpleMap<URI, IMarker[]>;
|
||||
private markersByResource: Map.LinkedMap<URI, IMarker[]>;
|
||||
|
||||
private _filteredResources:Resource[];
|
||||
private _nonFilteredResources:Resource[];
|
||||
private _filterOptions:FilterOptions;
|
||||
|
||||
constructor(markers: IMarker[]= []) {
|
||||
this.markersByResource= new Map.SimpleMap<URI, IMarker[]>();
|
||||
this.markersByResource= new Map.LinkedMap<URI, IMarker[]>();
|
||||
this._filterOptions= new FilterOptions();
|
||||
this.update(markers);
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
|||
|
||||
class EditorInputCache {
|
||||
|
||||
private cache: Map.SimpleMap<URI, TPromise<DiffEditorInput>>;
|
||||
private cache: Map.LinkedMap<URI, TPromise<DiffEditorInput>>;
|
||||
|
||||
constructor(private replaceService: ReplaceService, private editorService: IWorkbenchEditorService,
|
||||
private modelService: IModelService) {
|
||||
this.cache= new Map.SimpleMap<URI, TPromise<DiffEditorInput>>();
|
||||
this.cache= new Map.LinkedMap<URI, TPromise<DiffEditorInput>>();
|
||||
}
|
||||
|
||||
public hasInput(fileMatch: FileMatch): boolean {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
|
|||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise, PPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { SimpleMap } from 'vs/base/common/map';
|
||||
import { LinkedMap } from 'vs/base/common/map';
|
||||
import { ArraySet } from 'vs/base/common/set';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import * as Search from 'vs/platform/search/common/search';
|
||||
|
@ -100,7 +100,7 @@ export class FileMatch extends Disposable {
|
|||
private _resource: URI;
|
||||
private _model: IModel;
|
||||
private _modelListener: IDisposable;
|
||||
private _matches: SimpleMap<string, Match>;
|
||||
private _matches: LinkedMap<string, Match>;
|
||||
private _removedMatches: ArraySet<string>;
|
||||
private _selectedMatch: Match;
|
||||
|
||||
|
@ -111,7 +111,7 @@ export class FileMatch extends Disposable {
|
|||
@IModelService private modelService: IModelService, @IReplaceService private replaceService: IReplaceService) {
|
||||
super();
|
||||
this._resource = this.rawMatch.resource;
|
||||
this._matches = new SimpleMap<string, Match>();
|
||||
this._matches = new LinkedMap<string, Match>();
|
||||
this._removedMatches = new ArraySet<string>();
|
||||
this._updateScheduler = new RunOnceScheduler(this.updateMatches.bind(this), 250);
|
||||
|
||||
|
@ -172,7 +172,7 @@ export class FileMatch extends Disposable {
|
|||
if (!this._model) {
|
||||
return;
|
||||
}
|
||||
this._matches = new SimpleMap<string, Match>();
|
||||
this._matches = new LinkedMap<string, Match>();
|
||||
let matches = this._model
|
||||
.findMatches(this._query.pattern, this._model.getFullModelRange(), this._query.isRegExp, this._query.isCaseSensitive, this._query.isWordMatch);
|
||||
|
||||
|
@ -298,8 +298,8 @@ export class SearchResult extends Disposable {
|
|||
private _onChange = this._register(new Emitter<IChangeEvent>());
|
||||
public onChange: Event<IChangeEvent> = this._onChange.event;
|
||||
|
||||
private _fileMatches: SimpleMap<URI, FileMatch>;
|
||||
private _unDisposedFileMatches: SimpleMap<URI, FileMatch>;
|
||||
private _fileMatches: LinkedMap<URI, FileMatch>;
|
||||
private _unDisposedFileMatches: LinkedMap<URI, FileMatch>;
|
||||
private _query: Search.IPatternInfo = null;
|
||||
private _showHighlights: boolean;
|
||||
private _replacingAll: boolean = false;
|
||||
|
@ -307,8 +307,8 @@ export class SearchResult extends Disposable {
|
|||
constructor(private _searchModel: SearchModel, @IReplaceService private replaceService: IReplaceService, @ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService) {
|
||||
super();
|
||||
this._fileMatches = new SimpleMap<URI, FileMatch>();
|
||||
this._unDisposedFileMatches = new SimpleMap<URI, FileMatch>();
|
||||
this._fileMatches = new LinkedMap<URI, FileMatch>();
|
||||
this._unDisposedFileMatches = new LinkedMap<URI, FileMatch>();
|
||||
}
|
||||
|
||||
public set query(query: Search.IPatternInfo) {
|
||||
|
|
Loading…
Reference in a new issue