InputReader

class InputReader @JvmOverloads constructor(stream: InputStream = DEFAULT_STREAM, bufferSize: Int = DEFAULT_BUFFER_SIZE)

A fast input reader for any java.io.InputStream (especially System.in).

This reader is optimized for competitive-programming style input and assumes well-formed data (it does not perform validation).

Author

William Fiset, william.alexandre.fiset@gmail.com. Auto translated to Kotlin by IntelliJ.

Constructors

Link copied to clipboard
@JvmOverloads
constructor(stream: InputStream = DEFAULT_STREAM, bufferSize: Int = DEFAULT_BUFFER_SIZE)
constructor(bufferSize: Int)

Create an InputReader that reads from standard input.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun close()

Closes the underlying input stream.

Link copied to clipboard
fun nextByte(): Byte

Reads a single byte from the input stream.

Link copied to clipboard
fun nextByteArray(n: Int): ByteArray

Reads an array of n byte values.

Link copied to clipboard
fun nextByteArray1(n: Int): ByteArray

Reads a 1-based byte array of size n + 1 (index 0 unused).

Link copied to clipboard
fun nextByteMatrix(rows: Int, cols: Int): Array<ByteArray?>

Reads a rows x cols matrix of bytes.

Link copied to clipboard
fun nextByteMatrix1(rows: Int, cols: Int): Array<ByteArray?>

Reads a 1-based (rows + 1) x (cols + 1) matrix of bytes.

Link copied to clipboard
fun nextDouble(): Double

Reads the next token and parses it as a Double.

Link copied to clipboard
fun nextDoubleArray(n: Int): DoubleArray

Reads an array of n double values.

Link copied to clipboard
fun nextDoubleArray1(n: Int): DoubleArray

Reads a 1-based double array of size n + 1 (index 0 unused).

Link copied to clipboard
fun nextDoubleArrayFast(n: Int): DoubleArray

Reads an array of n doubles using nextDoubleFast.

Link copied to clipboard
fun nextDoubleArrayFast1(n: Int): DoubleArray

Reads a 1-based double array of size n + 1 using nextDoubleFast.

Link copied to clipboard
fun nextDoubleFast(): Double

Reads the next token as a Double using a faster parsing path.

Link copied to clipboard
fun nextDoubleMatrix(rows: Int, cols: Int): Array<DoubleArray?>

Reads a rows x cols matrix of doubles.

Link copied to clipboard
fun nextDoubleMatrix1(rows: Int, cols: Int): Array<DoubleArray?>

Reads a 1-based (rows + 1) x (cols + 1) matrix of doubles.

Link copied to clipboard
fun nextDoubleMatrixFast(rows: Int, cols: Int): Array<DoubleArray?>

Reads a rows x cols matrix of doubles using nextDoubleFast.

Link copied to clipboard
fun nextDoubleMatrixFast1(rows: Int, cols: Int): Array<DoubleArray?>

Reads a 1-based (rows + 1) x (cols + 1) matrix of doubles using nextDoubleFast.

Link copied to clipboard
fun nextInt(): Int

Reads a 32 bit signed integer from input stream.

Link copied to clipboard
fun nextIntArray(n: Int): IntArray

Reads an array of n integer values.

Link copied to clipboard
fun nextIntArray1(n: Int): IntArray

Reads a 1-based integer array of size n + 1 (index 0 unused).

Link copied to clipboard
fun nextIntMatrix(rows: Int, cols: Int): Array<IntArray?>

Reads a rows x cols matrix of integers.

Link copied to clipboard
fun nextIntMatrix1(rows: Int, cols: Int): Array<IntArray?>

Reads a 1-based (rows + 1) x (cols + 1) matrix of integers.

Link copied to clipboard
fun nextLine(): String?

Reads a line from the input stream.

Link copied to clipboard
fun nextLong(): Long

Reads a 64 bit signed long from input stream.

Link copied to clipboard
fun nextLongArray(n: Int): LongArray

Reads an array of n long values.

Link copied to clipboard
fun nextLongArray1(n: Int): LongArray

Reads a 1-based long array of size n + 1 (index 0 unused).

Link copied to clipboard
fun nextLongMatrix(rows: Int, cols: Int): Array<LongArray?>

Reads a rows x cols matrix of longs.

Link copied to clipboard
fun nextLongMatrix1(rows: Int, cols: Int): Array<LongArray?>

Reads a 1-based (rows + 1) x (cols + 1) matrix of longs.

Link copied to clipboard
fun nextString(): String?

Reads the next token as a string.

Link copied to clipboard
fun nextStringArray(n: Int): Array<String?>

Reads an array of n string tokens.

Link copied to clipboard
fun nextStringArray1(n: Int): Array<String?>

Reads a 1-based string array of size n + 1 (index 0 unused).

Link copied to clipboard
fun nextStringMatrix(rows: Int, cols: Int): Array<Array<String?>?>

Reads a rows x cols matrix of string tokens.

Link copied to clipboard
fun nextStringMatrix1(rows: Int, cols: Int): Array<Array<String?>?>

Reads a 1-based (rows + 1) x (cols + 1) matrix of string tokens.