Java Code Examples for java.util.function.IntSupplier#getAsInt()
The following examples show how to use
java.util.function.IntSupplier#getAsInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnsignedLEB128.java From java-dcp-client with Apache License 2.0 | 6 votes |
private static long read(IntSupplier byteSource) { long result = 0; for (int i = 0; ; i++) { final int b = byteSource.getAsInt(); final long low7Bits = b & 0x7f; final boolean done = (b & 0x80) == 0; // The first 9 groups of 7 bits are guaranteed to fit (9 * 7 = 63 bits). // That leaves room for only the low-order bit from the 10th group (which has index 9) if (i == 9 && (b & 0xfe) != 0) { throw new ArithmeticException("Value is larger than 64-bits"); } result |= low7Bits << (7 * i); if (done) { return result; } } }
Example 2
Source File: FishUtf8.java From antsdb with GNU Lesser General Public License v3.0 | 6 votes |
public static int compare(long pX, long pY) { IntSupplier scannerX = new FishUtf8(pX).scan(); IntSupplier scannerY = new FishUtf8(pY).scan(); for (;;) { int x = scannerX.getAsInt(); int y = scannerY.getAsInt(); int result = x - y; if (result != 0) { return result; } if ((x == -1) && (y == -1)) { break; } } return 0; }
Example 3
Source File: Decoder.java From antsdb with GNU Lesser General Public License v3.0 | 5 votes |
public default String toString(IntSupplier input) { StringBuilder buf = new StringBuilder(); IntSupplier output = mapDecode(input); for (int ch = output.getAsInt(); ch != -1; ch=output.getAsInt()) { buf.append((char)ch); } return buf.toString(); }
Example 4
Source File: VdmComparator.java From antsdb with GNU Lesser General Public License v3.0 | 5 votes |
private int compString(long px, long py, Operator x, Operator y) { IntSupplier scanX = FishString.scan(px); IntSupplier scanY = FishString.scan(py); for (;;) { int chx = scanX.getAsInt(); int chy = scanY.getAsInt(); if ((chx == -1) && (chy == -1)) { break; } // skip trailing space if (chx == -1) { if (chy == ' ') { continue; } } if (chy == -1) { if (chx == ' ') { continue; } } int result = chx - chy; if (result != 0) { return result; } } return 0; }
Example 5
Source File: SystemModulesPlugin.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
DedupSetBuilder(IntSupplier localVarSupplier) { this.stringSetVar = localVarSupplier.getAsInt(); this.enumSetVar = localVarSupplier.getAsInt(); this.localVarSupplier = localVarSupplier; }
Example 6
Source File: OptionalInt.java From j4ts with Apache License 2.0 | 4 votes |
public int orElseGet(IntSupplier other) { return present ? ref : other.getAsInt(); }
Example 7
Source File: RaftTestUtil.java From ratis with Apache License 2.0 | 4 votes |
static void delay(IntSupplier getDelayMs) throws InterruptedException { final int t = getDelayMs.getAsInt(); if (t > 0) { Thread.sleep(t); } }
Example 8
Source File: OptionalInt.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 9
Source File: OptionalInt.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 10
Source File: OptionalInt.java From Java8CN with Apache License 2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 11
Source File: OptionalInt.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 12
Source File: OptionalInt.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * If a value is present, returns the value, otherwise returns the result * produced by the supplying function. * * @param supplier the supplying function that produces a value to be returned * @return the value, if present, otherwise the result produced by the * supplying function * @throws NullPointerException if no value is present and the supplying * function is {@code null} */ public int orElseGet(IntSupplier supplier) { return isPresent ? value : supplier.getAsInt(); }
Example 13
Source File: OptionalInt.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * If a value is present, returns the value, otherwise returns the result * produced by the supplying function. * * @param supplier the supplying function that produces a value to be returned * @return the value, if present, otherwise the result produced by the * supplying function * @throws NullPointerException if no value is present and the supplying * function is {@code null} */ public int orElseGet(IntSupplier supplier) { return isPresent ? value : supplier.getAsInt(); }
Example 14
Source File: OptionalInt.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 15
Source File: OptionalInt.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 16
Source File: OptionalInt.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 17
Source File: OptionalInt.java From desugar_jdk_libs with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 18
Source File: OptionalInt.java From JDKSourceCode1.8 with MIT License | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 19
Source File: OptionalInt.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }
Example 20
Source File: OptionalInt.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Return the value if present, otherwise invoke {@code other} and return * the result of that invocation. * * @param other a {@code IntSupplier} whose result is returned if no value * is present * @return the value if present otherwise the result of {@code other.getAsInt()} * @throws NullPointerException if value is not present and {@code other} is * null */ public int orElseGet(IntSupplier other) { return isPresent ? value : other.getAsInt(); }