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

Method getLast

corpus/java/training/guava/collect/Iterators.java:830–837  ·  view source on GitHub ↗

Advances iterator to the end, returning the last element. @return the last element of iterator @throws NoSuchElementException if the iterator is empty

(Iterator<T> iterator)

Source from the content-addressed store, hash-verified

828 * @throws NoSuchElementException if the iterator is empty
829 */
830 public static <T> T getLast(Iterator<T> iterator) {
831 while (true) {
832 T current = iterator.next();
833 if (!iterator.hasNext()) {
834 return current;
835 }
836 }
837 }
838
839 /**
840 * Advances {@code iterator} to the end, returning the last element or

Callers 1

getLastMethod · 0.95

Calls 2

nextMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected