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

Method getLast

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

Returns the last element of iterable. If iterable is a List with RandomAccess support, then this operation is guaranteed to be O(1). @return the last element of iterable @throws NoSuchElementException if the iterable is empty

(Iterable<T> iterable)

Source from the content-addressed store, hash-verified

762 * @throws NoSuchElementException if the iterable is empty
763 */
764 public static <T> T getLast(Iterable<T> iterable) {
765 // TODO(kevinb): Support a concurrently modified collection?
766 if (iterable instanceof List) {
767 List<T> list = (List<T>) iterable;
768 if (list.isEmpty()) {
769 throw new NoSuchElementException();
770 }
771 return getLastInNonemptyList(list);
772 }
773
774 return Iterators.getLast(iterable.iterator());
775 }
776
777 /**
778 * Returns the last element of {@code iterable} or {@code defaultValue} if

Callers 6

ComplementRangesMethod · 0.95
peekMethod · 0.45
nextMethod · 0.45
computeNextMethod · 0.45
nextMethod · 0.45
computeNextMethod · 0.45

Calls 6

getLastInNonemptyListMethod · 0.95
getLastMethod · 0.95
castMethod · 0.95
castMethod · 0.95
isEmptyMethod · 0.65
iteratorMethod · 0.65

Tested by

no test coverage detected