32
33
private static getKey(chr: string): number {
34
>
let key = this.chrKeys.get(chr);
utils.ts
35
>
if (key === undefined) {
36
>
key = this.chrKeys.size;
37
>
this.chrKeys.set(chr, key);
38
>
}
39
>
return key;
40
>
}
41
42
private readonly totalCount: number;
43
private readonly histogram: number[] = [];
44
constructor(
45
>
public readonly range: LineRange,
utils.ts
46
>
public readonly lines: string[],
47
>
public readonly source: DetailedLineRangeMapping,
48
>
) {
49
>
let counter = 0;
50
>
for (let i = range.startLineNumber - 1; i < range.endLineNumberExclusive - 1; i++) {
51
>
const line = lines[i];
52
>
for (let j = 0; j < line.length; j++) {
53
>
counter++;
54
>
const chr = line[j];
55
>
const key = LineRangeFragment.getKey(chr);
56
>
this.histogram[key] = (this.histogram[key] || 0) + 1;
57
>
}
58
>
counter++;
59
>
const key = LineRangeFragment.getKey('\n');
60
>
this.histogram[key] = (this.histogram[key] || 0) + 1;
61
>
}
62
>
63
>
this.totalCount = counter;
64
>
}
65
66
public computeSimilarity(other: LineRangeFragment): number {