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

Method copyOf

output/java_guava/1.4.16/ImmutableSet.java:248–265  ·  view source on GitHub ↗

Returns an immutable set containing each of elements, minus duplicates, in the order each appears first in the source collection. Performance note: This method will sometimes recognize that the actual copy operation is unnecessary; for example, copyOf(copyOf(anArrayList))

(Collection<? extends E> elements)

Source from the content-addressed store, hash-verified

246
247
248 public static <E> ImmutableSet<E> copyOf(Collection<? extends E> elements) {
249 /*
250 * TODO(lowasser): consider checking for ImmutableAsList here
251 * TODO(lowasser): consider checking for Multiset here
252 */
253 if (elements instanceof ImmutableSet
254 && !(elements instanceof ImmutableSortedSet)) {
255 @SuppressWarnings("unchecked") // all supported methods are covariant
256 ImmutableSet<E> set = (ImmutableSet<E>) elements;
257 if (!set.isPartialView()) {
258 return set;
259 }
260 } else if (elements instanceof EnumSet) {
261 return copyOfEnumSet((EnumSet) elements);
262 }
263 Object[] array = elements.toArray();
264 return construct(array.length, array);
265 }
266
267 /**
268 * Returns an immutable set containing each of {@code elements}, minus duplicates, in the order

Callers 14

edgesConnectingMethod · 0.95
ofImmutableMethod · 0.95
rawTypesMethod · 0.95
rawTypesMethod · 0.95
toSetMethod · 0.95
loadMethod · 0.95
charsetMethod · 0.95
valueSetMethod · 0.95
FileByteSinkMethod · 0.95
immutableCopyMethod · 0.95
createMethod · 0.95
forCellsInternalMethod · 0.95

Calls 12

copyOfEnumSetMethod · 0.95
constructMethod · 0.95
ofMethod · 0.95
iteratorMethod · 0.65
nextMethod · 0.65
addAllMethod · 0.65
addMethod · 0.65
isPartialViewMethod · 0.45
toArrayMethod · 0.45
hasNextMethod · 0.45
buildMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected