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

Method get

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

Advances iterator position + 1 times, returning the element at the positionth position. @param position position of the element to return @return the element at the specified position in iterator @throws IndexOutOfBoundsException if position is negative or

(Iterator<T> iterator, int position)

Source from the content-addressed store, hash-verified

766 * {@code iterator}
767 */
768 public static <T> T get(Iterator<T> iterator, int position) {
769 checkNonnegative(position);
770 int skipped = advance(iterator, position);
771 if (!iterator.hasNext()) {
772 throw new IndexOutOfBoundsException(
773 "position ("
774 + position
775 + ") must be less than the number of elements that remained ("
776 + skipped
777 + ")");
778 }
779 return iterator.next();
780 }
781
782 static void checkNonnegative(int position) {
783 if (position < 0) {

Callers 1

getMethod · 0.95

Calls 5

checkNonnegativeMethod · 0.95
advanceMethod · 0.95
getNextMethod · 0.95
nextMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected