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

Method getLast

output/java_guava/1.4.16/Iterables.java:826–836  ·  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

824
825
826 public static <T> T getLast(Iterable<T> iterable) {
827 // TODO(kevinb): Support a concurrently modified collection?
828 if (iterable instanceof List) {
829 List<T> list = (List<T>) iterable;
830 if (list.isEmpty()) {
831 throw new NoSuchElementException();
832 }
833 return getLastInNonemptyList(list);
834 }
835 return Iterators.getLast(iterable.iterator());
836 }
837
838 /**
839 * 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