MCPcopy Create free account
hub / github.com/antlr/codebuff / remove

Method remove

corpus/java/training/guava/collect/TreeRangeMap.java:160–209  ·  view source on GitHub ↗
(Range<K> rangeToRemove)

Source from the content-addressed store, hash-verified

158 }
159
160 @Override
161 public void remove(Range<K> rangeToRemove) {
162 if (rangeToRemove.isEmpty()) {
163 return;
164 }
165
166 /*
167 * The comments for this method will use [ ] to indicate the bounds of rangeToRemove and ( ) to
168 * indicate the bounds of ranges in the range map.
169 */
170 Map.Entry<Cut<K>, RangeMapEntry<K, V>> mapEntryBelowToTruncate =
171 entriesByLowerBound.lowerEntry(rangeToRemove.lowerBound);
172 if (mapEntryBelowToTruncate != null) {
173 // we know ( [
174 RangeMapEntry<K, V> rangeMapEntry = mapEntryBelowToTruncate.getValue();
175 if (rangeMapEntry.getUpperBound().compareTo(rangeToRemove.lowerBound) > 0) {
176 // we know ( [ )
177 if (rangeMapEntry.getUpperBound().compareTo(rangeToRemove.upperBound) > 0) {
178 // we know ( [ ] ), so insert the range ] ) back into the map --
179 // it's being split apart
180 putRangeMapEntry(
181 rangeToRemove.upperBound,
182 rangeMapEntry.getUpperBound(),
183 mapEntryBelowToTruncate.getValue().getValue());
184 }
185 // overwrite mapEntryToTruncateBelow with a truncated range
186 putRangeMapEntry(
187 rangeMapEntry.getLowerBound(),
188 rangeToRemove.lowerBound,
189 mapEntryBelowToTruncate.getValue().getValue());
190 }
191 }
192
193 Map.Entry<Cut<K>, RangeMapEntry<K, V>> mapEntryAboveToTruncate =
194 entriesByLowerBound.lowerEntry(rangeToRemove.upperBound);
195 if (mapEntryAboveToTruncate != null) {
196 // we know ( ]
197 RangeMapEntry<K, V> rangeMapEntry = mapEntryAboveToTruncate.getValue();
198 if (rangeMapEntry.getUpperBound().compareTo(rangeToRemove.upperBound) > 0) {
199 // we know ( ] ), and since we dealt with truncating below already,
200 // we know [ ( ] )
201 putRangeMapEntry(
202 rangeToRemove.upperBound,
203 rangeMapEntry.getUpperBound(),
204 mapEntryAboveToTruncate.getValue().getValue());
205 entriesByLowerBound.remove(rangeToRemove.lowerBound);
206 }
207 }
208 entriesByLowerBound.subMap(rangeToRemove.lowerBound, rangeToRemove.upperBound).clear();
209 }
210
211 @Override
212 public Map<Range<K>, V> asMapOfRanges() {

Callers 1

putMethod · 0.95

Calls 11

putRangeMapEntryMethod · 0.95
isEmptyMethod · 0.65
getValueMethod · 0.65
removeMethod · 0.65
clearMethod · 0.65
lowerEntryMethod · 0.45
compareToMethod · 0.45
getUpperBoundMethod · 0.45
getLowerBoundMethod · 0.45
subMapMethod · 0.45
checkNotNullMethod · 0.45

Tested by

no test coverage detected