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

Method getFirst

corpus/java/training/guava/collect/Iterables.java:752–755  ·  view source on GitHub ↗

Returns the first element in iterable or defaultValue if the iterable is empty. The Iterators analog to this method is Iterators#getNext. If no default value is desired (and the caller instead wants a NoSuchElementException to be thrown), it is recommende

(Iterable<? extends T> iterable, @Nullable T defaultValue)

Source from the content-addressed store, hash-verified

750 * @since 7.0
751 */
752 @Nullable
753 public static <T> T getFirst(Iterable<? extends T> iterable, @Nullable T defaultValue) {
754 return Iterators.getNext(iterable.iterator(), defaultValue);
755 }
756
757 /**
758 * Returns the last element of {@code iterable}. If {@code iterable} is a {@link List} with

Callers 6

ceilingMethod · 0.95
higherMethod · 0.95
ceilingMethod · 0.95
higherMethod · 0.95
standardFirstEntryMethod · 0.95
standardLastEntryMethod · 0.95

Calls 2

getNextMethod · 0.95
iteratorMethod · 0.65

Tested by

no test coverage detected