(value)
| 139 | } |
| 140 | |
| 141 | removeOne(value) { |
| 142 | if (this.intervals !== null) { |
| 143 | for (let i = 0; i < this.intervals.length; i++) { |
| 144 | const existing = this.intervals[i]; |
| 145 | // intervals are ordered |
| 146 | if (value < existing.start) { |
| 147 | return; |
| 148 | } |
| 149 | // check for single value range |
| 150 | else if (value === existing.start && value === existing.stop - 1) { |
| 151 | this.intervals.splice(i, 1); |
| 152 | return; |
| 153 | } |
| 154 | // check for lower boundary |
| 155 | else if (value === existing.start) { |
| 156 | this.intervals[i] = new Interval(existing.start + 1, existing.stop); |
| 157 | return; |
| 158 | } |
| 159 | // check for upper boundary |
| 160 | else if (value === existing.stop - 1) { |
| 161 | this.intervals[i] = new Interval(existing.start, existing.stop - 1); |
| 162 | return; |
| 163 | } |
| 164 | // split existing range |
| 165 | else if (value < existing.stop - 1) { |
| 166 | const replace = new Interval(existing.start, value); |
| 167 | existing.start = value + 1; |
| 168 | this.intervals.splice(i, 0, replace); |
| 169 | return; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | toString(literalNames, symbolicNames, elemsAreChar) { |
| 176 | literalNames = literalNames || null; |
no outgoing calls
no test coverage detected