(Range<K> rangeToRemove)
| 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public void remove(Range<K> rangeToRemove) { |
| 213 | if (rangeToRemove.isEmpty()) { |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | /* |
| 218 | * The comments for this method will use [ ] to indicate the bounds of rangeToRemove and ( ) to |
| 219 | * indicate the bounds of ranges in the range map. |
| 220 | */ |
| 221 | Entry<Cut<K>, RangeMapEntry<K, V>> mapEntryBelowToTruncate = |
| 222 | entriesByLowerBound.lowerEntry(rangeToRemove.lowerBound); |
| 223 | if (mapEntryBelowToTruncate != null) { |
| 224 | // we know ( [ |
| 225 | RangeMapEntry<K, V> rangeMapEntry = mapEntryBelowToTruncate.getValue(); |
| 226 | if (rangeMapEntry.getUpperBound().compareTo(rangeToRemove.lowerBound) > 0) { |
| 227 | // we know ( [ ) |
| 228 | if (rangeMapEntry.getUpperBound().compareTo(rangeToRemove.upperBound) > 0) { |
| 229 | // we know ( [ ] ), so insert the range ] ) back into the map -- |
| 230 | // it's being split apart |
| 231 | putRangeMapEntry( |
| 232 | rangeToRemove.upperBound, |
| 233 | rangeMapEntry.getUpperBound(), |
| 234 | mapEntryBelowToTruncate.getValue().getValue()); |
| 235 | } |
| 236 | // overwrite mapEntryToTruncateBelow with a truncated range |
| 237 | putRangeMapEntry( |
| 238 | rangeMapEntry.getLowerBound(), |
| 239 | rangeToRemove.lowerBound, |
| 240 | mapEntryBelowToTruncate.getValue().getValue()); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | Entry<Cut<K>, RangeMapEntry<K, V>> mapEntryAboveToTruncate = |
| 245 | entriesByLowerBound.lowerEntry(rangeToRemove.upperBound); |
| 246 | if (mapEntryAboveToTruncate != null) { |
| 247 | // we know ( ] |
| 248 | RangeMapEntry<K, V> rangeMapEntry = mapEntryAboveToTruncate.getValue(); |
| 249 | if (rangeMapEntry.getUpperBound().compareTo(rangeToRemove.upperBound) > 0) { |
| 250 | // we know ( ] ), and since we dealt with truncating below already, |
| 251 | // we know [ ( ] ) |
| 252 | putRangeMapEntry( |
| 253 | rangeToRemove.upperBound, |
| 254 | rangeMapEntry.getUpperBound(), |
| 255 | mapEntryAboveToTruncate.getValue().getValue()); |
| 256 | } |
| 257 | } |
| 258 | entriesByLowerBound.subMap(rangeToRemove.lowerBound, rangeToRemove.upperBound).clear(); |
| 259 | } |
| 260 | |
| 261 | private void split(Cut<K> cut) { |
| 262 | /* |
no test coverage detected