get method
Gets the Token at the specified index
in the stream. When
the preconditions of this method are met, the return value is non-null.
The preconditions for this method are the same as the preconditions of {@link IntStream#seek}. If the behavior of {@code seek(index)} is unspecified for the current state and given [index], then the behavior of this method is also unspecified.
The symbol referred to by [index] differs from {@code seek()} only in the case of filtering streams where [index] lies before the end of the stream. Unlike {@code seek()}, this method does not adjust [index] to point to a non-ignored symbol.
@throws IllegalArgumentException if {code index} is less than 0 @throws UnsupportedOperationException if the stream does not support retrieving the token at the specified index
Implementation
@override
Token get(int i) {
if (i < 0 || i >= tokens.length) {
throw RangeError.index(i, tokens);
}
return tokens[i];
}