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

Method first

corpus/java/training/guava/collect/FluentIterable.java:489–492  ·  view source on GitHub ↗

Returns an Optional containing the first element in this fluent iterable. If the iterable is empty, Optional.absent() is returned. Stream equivalent: if the goal is to obtain any element, stream.findAny(); if it must specifically be the first element

()

Source from the content-addressed store, hash-verified

487 * {@code iterator().next()} or {@link Iterables#getFirst} instead.
488 */
489 public final Optional<E> first() {
490 Iterator<E> iterator = iterable.iterator();
491 return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent();
492 }
493
494 /**
495 * Returns an {@link Optional} containing the last element in this fluent iterable. If the

Callers

nothing calls this directly

Calls 5

ofMethod · 0.95
absentMethod · 0.95
iteratorMethod · 0.65
nextMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected