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

Method get

guava/src/com/google/common/collect/Iterables.java:768–774  ·  view source on GitHub ↗

Returns the element at the specified position in an iterable. <p><b>{@code Stream} equivalent:</b> {@code stream.skip(position).findFirst().get()} (throws {@code NoSuchElementException} if out of bounds) @param position position of the element to return @return the element at the specified positio

(Iterable<T> iterable, int position)

Source from the content-addressed store, hash-verified

766 * the size of {@code iterable}
767 */
768 @ParametricNullness
769 public static <T extends @Nullable Object> T get(Iterable<T> iterable, int position) {
770 checkNotNull(iterable);
771 return (iterable instanceof List)
772 ? ((List<T>) iterable).get(position)
773 : Iterators.get(iterable.iterator(), position);
774 }
775
776 /**
777 * Returns the element at the specified position in an iterable or a default value otherwise.

Callers 11

getMethod · 0.95
testGetOnAbcMethod · 0.95
testGetOnEmptyMethod · 0.95
invokeAnyMethod · 0.95
pickInstanceMethod · 0.95

Calls 8

getMethod · 0.95
checkNonnegativeMethod · 0.95
advanceMethod · 0.95
getNextMethod · 0.95
getMethod · 0.65
iteratorMethod · 0.65
sizeMethod · 0.65
checkNotNullMethod · 0.45

Tested by 10

testGetOnAbcMethod · 0.76
testGetOnEmptyMethod · 0.76
invokeAnyMethod · 0.76
pickInstanceMethod · 0.76