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.obj.BiObjFloatToShortFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjFloatToShortFunction}. 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 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 BiObjFloatToShortFunction}. * @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 BiObjFloatToShortFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Float>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjFloatToShortFunction<T, U> & Memoized) (t, u, value) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjShortToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjShortToFloatFunction}. 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 . j a v 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 BiObjShortToFloatFunction}. * @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 BiObjShortToFloatFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Short>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjShortToFloatFunction<T, U> & Memoized) (t, u, value) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjByteToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjByteToDoubleFunction}. 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 .j a v a2 s . com * 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 BiObjByteToDoubleFunction}. * @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 BiObjByteToDoubleFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Byte>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjByteToDoubleFunction<T, U> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjLongToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjLongToDoubleFunction}. 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>// www . j av 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 BiObjLongToDoubleFunction}. * @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 BiObjLongToDoubleFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Long>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjLongToDoubleFunction<T, U> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjCharToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjCharToDoubleFunction}. 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 BiObjCharToDoubleFunction}. * @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 BiObjCharToDoubleFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Character>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjCharToDoubleFunction<T, U> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjDoubleToFloatFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjDoubleToFloatFunction}. 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>//www . jav 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 BiObjDoubleToFloatFunction}. * @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 BiObjDoubleToFloatFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, Float> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjDoubleToFloatFunction<T, U> & Memoized) (t, u, value) -> { final float returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsFloat(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjDoubleToShortFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjDoubleToShortFunction}. 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 .ja v a 2s.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 BiObjDoubleToShortFunction}. * @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 BiObjDoubleToShortFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Double>, Short> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjDoubleToShortFunction<T, U> & Memoized) (t, u, value) -> { final short returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsShort(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjBooleanToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjBooleanToDoubleFunction}. 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>/*www .java 2s .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 BiObjBooleanToDoubleFunction}. * @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 BiObjBooleanToDoubleFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Boolean>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjBooleanToDoubleFunction<T, U> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjFloatToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjFloatToDoubleFunction}. 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 BiObjFloatToDoubleFunction}. * @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 BiObjFloatToDoubleFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Float>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjFloatToDoubleFunction<T, U> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjShortToDoubleFunction.java
/** * Returns a memoized (caching) version of this {@link BiObjShortToDoubleFunction}. 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 a 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 BiObjShortToDoubleFunction}. * @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 BiObjShortToDoubleFunction<T, U> memoized() { if (isMemoized()) { return this; } else { final Map<Triple<T, U, Short>, Double> cache = new ConcurrentHashMap<>(); final Object lock = new Object(); return (BiObjShortToDoubleFunction<T, U> & Memoized) (t, u, value) -> { final double returnValue; synchronized (lock) { returnValue = cache.computeIfAbsent(Triple.of(t, u, value), key -> applyAsDouble(key.getLeft(), key.getMiddle(), key.getRight())); } return returnValue; }; } }