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

Method subMap

corpus/java/training/guava/collect/Maps.java:4160–4184  ·  view source on GitHub ↗

Returns a view of the portion of map whose keys are contained by range. This method delegates to the appropriate methods of NavigableMap (namely NavigableMap#subMap(Object, boolean, Object, boolean) subMap(), NavigableMap#tailMap(Object, boolean) tailMap()

(
      NavigableMap<K, V> map, Range<K> range)

Source from the content-addressed store, hash-verified

4158 * @since 20.0
4159 */
4160 @Beta
4161 @GwtIncompatible // NavigableMap
4162 public static <K extends Comparable<? super K>, V> NavigableMap<K, V> subMap(
4163 NavigableMap<K, V> map, Range<K> range) {
4164 if (map.comparator() != null
4165 && map.comparator() != Ordering.natural()
4166 && range.hasLowerBound()
4167 && range.hasUpperBound()) {
4168 checkArgument(
4169 map.comparator().compare(range.lowerEndpoint(), range.upperEndpoint()) <= 0,
4170 "map is using a custom comparator which is inconsistent with the natural ordering.");
4171 }
4172 if (range.hasLowerBound() && range.hasUpperBound()) {
4173 return map.subMap(
4174 range.lowerEndpoint(),
4175 range.lowerBoundType() == BoundType.CLOSED,
4176 range.upperEndpoint(),
4177 range.upperBoundType() == BoundType.CLOSED);
4178 } else if (range.hasLowerBound()) {
4179 return map.tailMap(range.lowerEndpoint(), range.lowerBoundType() == BoundType.CLOSED);
4180 } else if (range.hasUpperBound()) {
4181 return map.headMap(range.upperEndpoint(), range.upperBoundType() == BoundType.CLOSED);
4182 }
4183 return checkNotNull(map);
4184 }
4185}

Callers 10

subMapMethod · 0.45
subMapMethod · 0.45
subSetMethod · 0.45
subMapMethod · 0.45
subMapMethod · 0.45
subMapMethod · 0.45
subSetMethod · 0.45
subSetMethod · 0.45
subMapMethod · 0.45
removeMethod · 0.45

Calls 13

naturalMethod · 0.95
comparatorMethod · 0.65
hasLowerBoundMethod · 0.45
hasUpperBoundMethod · 0.45
checkArgumentMethod · 0.45
compareMethod · 0.45
lowerEndpointMethod · 0.45
upperEndpointMethod · 0.45
lowerBoundTypeMethod · 0.45
upperBoundTypeMethod · 0.45
tailMapMethod · 0.45
headMapMethod · 0.45

Tested by

no test coverage detected