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

Method copyOf

output/java_guava/1.4.17/ImmutableBiMap.java:273–284  ·  view source on GitHub ↗

Returns an immutable bimap containing the same entries as map. If map somehow contains entries with duplicate keys (for example, if it is a SortedMap whose comparator is not consistent with equals ), the results of this method are undefined. Despite the method name,

(Map<? extends K, ? extends V> map)

Source from the content-addressed store, hash-verified

271
272
273 public static <K, V> ImmutableBiMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
274 if (map instanceof ImmutableBiMap) {
275 @SuppressWarnings("unchecked") // safe since map is not writable
276 ImmutableBiMap<K, V> bimap = (ImmutableBiMap<K, V>) map;
277 // TODO(lowasser): if we need to make a copy of a BiMap because the
278 // forward map is a view, don't make a copy of the non-view delegate map
279 if (!bimap.isPartialView()) {
280 return bimap;
281 }
282 }
283 return copyOf(map.entrySet());
284 }
285
286 /**
287 * Returns an immutable bimap containing the given entries.

Callers 2

ofImmutableMethod · 0.95
ofImmutableMethod · 0.95

Calls 7

toArrayMethod · 0.95
ofMethod · 0.95
fromEntriesMethod · 0.95
entrySetMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
isPartialViewMethod · 0.45

Tested by

no test coverage detected