Input Reader
A very fast input reader to read data from any InputStream (System.in in particular). I primarily use this input reader for competitive programming to get an edge on the time required to read input. That being said, this input reader assumes you know what data types you are reading in and will not do any validation of input whatsoever!
Author
William Fiset, william.alexandre.fiset@gmail.com
Constructors
Create an InputReader that reads from standard input.
Functions
Read an array of n byte values
Read a 1-based byte array of size n+1
Read a two dimensional matrix of bytes of size rows x cols
Read a 1-based two dimensional matrix of bytes of size rows x cols
Reads a double from the input stream. The result is always identical to Double.parseDouble.
Read a double array of size n
Read a 1-based double array of size n+1
Quickly read an array of doubles
Quickly read a 1-based double array of size n+1
Reads a double value from the input stream, trading up to 1 ulp of accuracy for speed on high precision input. For values with at most ~15 significant digits (most input) this is identical to nextDouble(): same exact result, same speed. For 16+ significant digits, such as the full precision output of Double.toString, nextDouble() falls back to Double.parseDouble to stay exact, while this method keeps the fast path and may be off by 1 ulp (~2x faster).
Read a two dimensional matrix of doubles of size rows x cols
Read a 1-based two dimensional matrix of doubles of size rows x cols
Quickly read a two dimensional matrix of doubles of size rows x cols
Quickly read a 1-based two dimensional matrix of doubles of size rows x cols
Read an integer array of size n
Read a 1-based integer array of size n+1
Read a two dimensional matrix of ints of size rows x cols
Read a 1-based two dimensional matrix of ints of size rows x cols
Read a long array of size n
Read a 1-based long array of size n+1
Read a two dimensional matrix of longs of size rows x cols
Read a 1-based two dimensional matrix of longs of size rows x cols
Reads a string of characters from the input stream. The delimiter separating a string of characters is set to be: any ASCII value <= 32 meaning any spaces, new lines, tabs... or any non-ASCII byte (bytes are compared as signed values). Returns null at the end of the stream.
Read a string array of size n
Read a 1-based string array of size n+1