Merge pull request '哈哈' (#1) from fix-3216 into align-js-runtime-with-java-runtime

This commit is contained in:
forgetest1 2021-10-09 18:11:47 +08:00
commit 58119ce017
1 changed files with 7 additions and 2 deletions

View File

@ -7,11 +7,16 @@ const {Token} = require('./Token');
/* stop is not included! */
class Interval {
constructor(start, stop) {
this.start = start;
this.stop = stop;
}
clone() {
return new Interval(this.start, this.stop);
}
contains(item) {
return item >= this.start && item < this.stop;
}
@ -55,7 +60,7 @@ class IntervalSet {
addInterval(toAdd) {
if (this.intervals === null) {
this.intervals = [];
this.intervals.push(toAdd);
this.intervals.push(toAdd.clone());
} else {
// find insert pos
for (let pos = 0; pos < this.intervals.length; pos++) {
@ -78,7 +83,7 @@ class IntervalSet {
}
}
// greater than any existing
this.intervals.push(toAdd);
this.intervals.push(toAdd.clone());
}
}