List of usage examples for org.apache.commons.lang3.tuple Triple of
public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right)
Obtains an immutable triple of from three objects inferring the generic types.
This factory allows the triple to be created using inference to obtain the generic types.
From source file:at.gridtec.lambda4j.function.tri.conversion.TriFloatToLongFunction.java
/** * Returns a memoized (caching) version of this {@link TriFloatToLongFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>// w ww . j av a2s . c o m * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriFloatToLongFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriFloatToLongFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriFloatToLongFunction & Memoized) (value1, value2, value3) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriShortToLongFunction.java
/** * Returns a memoized (caching) version of this {@link TriShortToLongFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>/* w ww . ja v a 2s .c om*/ * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriShortToLongFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriShortToLongFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Short, Short, Short>, Long> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriShortToLongFunction & Memoized) (value1, value2, value3) -> { final long returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsLong(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriByteToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link TriByteToFloatFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>/*from www .ja v a 2s . c om*/ * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriByteToFloatFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriByteToFloatFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Byte, Byte, Byte>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriByteToFloatFunction & Memoized) (value1, value2, value3) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriByteToShortFunction.java
/** * Returns a memoized (caching) version of this {@link TriByteToShortFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>/* w w w . ja va 2 s.c o m*/ * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriByteToShortFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriByteToShortFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Byte, Byte, Byte>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriByteToShortFunction & Memoized) (value1, value2, value3) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriDoubleToIntFunction.java
/** * Returns a memoized (caching) version of this {@link TriDoubleToIntFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>/*from w w w . j av a 2 s . c om*/ * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriDoubleToIntFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriDoubleToIntFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Double, Double, Double>, Integer> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriDoubleToIntFunction & Memoized) (value1, value2, value3) -> { final int returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsInt(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriCharToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link TriCharToFloatFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>//from w w w . j a v a 2 s. co m * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriCharToFloatFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriCharToFloatFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Character, Character, Character>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriCharToFloatFunction & Memoized) (value1, value2, value3) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriCharToShortFunction.java
/** * Returns a memoized (caching) version of this {@link TriCharToShortFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>// w w w. ja v a2 s. c om * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriCharToShortFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriCharToShortFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Character, Character, Character>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriCharToShortFunction & Memoized) (value1, value2, value3) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriFloatToByteFunction.java
/** * Returns a memoized (caching) version of this {@link TriFloatToByteFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>/*from w w w.j a v a2 s . co m*/ * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriFloatToByteFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriFloatToByteFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriFloatToByteFunction & Memoized) (value1, value2, value3) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriShortToByteFunction.java
/** * Returns a memoized (caching) version of this {@link TriShortToByteFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>// ww w . j a v a2 s . c o m * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriShortToByteFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriShortToByteFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Short, Short, Short>, Byte> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriShortToByteFunction & Memoized) (value1, value2, value3) -> { final byte returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsByte(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.conversion.TriFloatToCharFunction.java
/** * Returns a memoized (caching) version of this {@link TriFloatToCharFunction}. Whenever it is called, the mapping * between the input parameters and the return value is preserved in a cache, making subsequent calls returning the * memoized value instead of computing the return value again. * <p>//from w w w. j av a 2 s . c o m * Unless the function and therefore the used cache will be garbage-collected, it will keep all memoized values * forever. * * @return A memoized (caching) version of this {@code TriFloatToCharFunction}. * @implSpec This implementation does not allow the input parameters or return value to be {@code null} for the * resulting memoized function, as the cache used internally does not permit {@code null} keys or values. * @implNote The returned memoized function can be safely used concurrently from multiple threads which makes it * thread-safe. */ @Nonnull default TriFloatToCharFunction memoized() { if (isMemoized()) { return this; } else { final Map<Triple<Float, Float, Float>, Character> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (TriFloatToCharFunction & Memoized) (value1, value2, value3) -> { final char returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(value1, value2, value3), key -> applyAsChar(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }