MCPcopy
hub / github.com/google/guava / toArray

Method toArray

guava/src/com/google/common/collect/Iterators.java:350–355  ·  view source on GitHub ↗

Copies an iterator's elements into an array. The iterator will be left exhausted: its {@code hasNext()} method will return {@code false}. @param iterator the iterator to copy @param type the type of the elements @return a newly-allocated array into which all the elements of the iterator have been c

(
      Iterator<? extends T> iterator, Class<@NonNull T> type)

Source from the content-addressed store, hash-verified

348 * @return a newly-allocated array into which all the elements of the iterator have been copied
349 */
350 @GwtIncompatible // Array.newInstance(Class, int)
351 public static <T extends @Nullable Object> T[] toArray(
352 Iterator<? extends T> iterator, Class<@NonNull T> type) {
353 List<T> list = Lists.newArrayList(iterator);
354 return Iterables.<T>toArray(list, type);
355 }
356
357 /**
358 * Adds all elements in {@code iterator} to {@code collection}. The iterator will be left

Callers 3

testToArrayEmptyMethod · 0.95
testToArraySingletonMethod · 0.95
testToArrayMethod · 0.95

Calls 2

newArrayListMethod · 0.95
toArrayMethod · 0.95

Tested by 3

testToArrayEmptyMethod · 0.76
testToArraySingletonMethod · 0.76
testToArrayMethod · 0.76