Class Lambda
eg. In this case, we want to supply the local variables name, and boneIdx to the supplied search: Anim findAnim(String name, int boneIdx) { // This will cause the variables 'anim' and 'boneIdx' to be allocated onto the VM, and need to be // garbage-collected. return m_allAnims.find( (anim) -> { return anim.Name.equals(name) && anim.boneIndices.contains(boneIdx); }); }
To avoid garbage-collection, we use Lambda capture, like so: Anim findAnim(String name, int boneIdx) { // The PZArrayUtil will call tryRelease on the supplied lambda object, thereby clearing it without garbage // collection. return PZArrayUtil.find(m_allAnims, Lambda.predicate(name, boneIdx, (anim, l_name, l_boneIdx) -> { return anim.Name.equals(l_name) && anim.boneIndices.contains(l_boneIdx); })); }
Lambda uses zombie.util.Pool to alloc and dealloc callbacks, meaning that all callbacks are recycled instead of left to the garbage-collector.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T1,
T2, T3, T4, T5, T6>
voidcapture
(T1 val1, T2 val2, T3 val3, T4 val4, T5 val5, T6 val6, Stacks.Params6.ICallback<T1, T2, T3, T4, T5, T6> captureConsumer) static <T1,
T2, T3, T4, T5>
voidcapture
(T1 val1, T2 val2, T3 val3, T4 val4, T5 val5, Stacks.Params5.ICallback<T1, T2, T3, T4, T5> captureConsumer) static <T1,
T2, T3, T4>
voidcapture
(T1 val1, T2 val2, T3 val3, T4 val4, Stacks.Params4.ICallback<T1, T2, T3, T4> captureConsumer) static <T1,
T2, T3> void capture
(T1 val1, T2 val2, T3 val3, Stacks.Params3.ICallback<T1, T2, T3> captureConsumer) static <T1,
T2> void capture
(T1 val1, T2 val2, Stacks.Params2.ICallback<T1, T2> captureConsumer) static <T1> void
capture
(T1 val1, Stacks.Params1.ICallback<T1> captureConsumer) static <E,
T1, T2> Comparator<E> comparator
(T1 val1, T2 val2, Comparators.Params2.ICallback<E, T1, T2> comparator) static <E,
T1> Comparator<E> comparator
(T1 val1, Comparators.Params1.ICallback<E, T1> comparator) static <E,
T1, T2, T3, T4, T5>
Consumer<E>consumer
(T1 val1, T2 val2, T3 val3, T4 val4, T5 val5, Consumers.Params5.ICallback<E, T1, T2, T3, T4, T5> consumer) static <E,
T1, T2, T3, T4>
Consumer<E>consumer
(T1 val1, T2 val2, T3 val3, T4 val4, Consumers.Params4.ICallback<E, T1, T2, T3, T4> consumer) static <E,
T1, T2, T3>
Consumer<E>consumer
(T1 val1, T2 val2, T3 val3, Consumers.Params3.ICallback<E, T1, T2, T3> consumer) static <E,
T1, T2> Consumer<E> consumer
(T1 val1, T2 val2, Consumers.Params2.ICallback<E, T1, T2> consumer) static <E,
T1> Consumer<E> consumer
(T1 val1, Consumers.Params1.ICallback<E, T1> consumer) static <E,
T1> boolean contains
(Predicate<Predicate<E>> findFunction, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) contains A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
F extends Iterable<E>, T1>
booleancontainsFrom
(BiPredicate<F, Predicate<E>> findFunction, F from, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) containsFrom A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
T1, R> R find
(Function<Predicate<E>, R> findFunction, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) find A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
T1, T2> void forEach
(Consumer<Consumer<E>> forEachFunction, T1 captureVal1, T2 captureVal2, Consumers.Params2.ICallback<E, T1, T2> lambdaFunc) forEach A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
T1> void forEach
(Consumer<Consumer<E>> forEachFunction, T1 captureVal1, Consumers.Params1.ICallback<E, T1> lambdaFunc) forEach A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
F, T1, T2>
voidforEachFrom
(BiConsumer<F, Consumer<E>> forEachFunction, F from, T1 captureVal1, T2 captureVal2, Consumers.Params2.ICallback<E, T1, T2> lambdaFunc) forEachFrom (Node, 2-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
F, T1> void forEachFrom
(BiConsumer<F, Consumer<E>> forEachFunction, F from, T1 captureVal1, Consumers.Params1.ICallback<E, T1> lambdaFunc) forEachFrom (Node, 1-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
T1, T2> void forEachFrom
(BiConsumer<List<E>, Consumer<E>> forEachFunction, List<E> from, T1 captureVal1, T2 captureVal2, Consumers.Params2.ICallback<E, T1, T2> lambdaFunc) forEachFrom (List, 2-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
T1> void forEachFrom
(BiConsumer<List<E>, Consumer<E>> forEachFunction, List<E> from, T1 captureVal1, Consumers.Params1.ICallback<E, T1> lambdaFunc) forEachFrom (List, 1-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <E,
T1> int indexOf
(IntSupplierFunction<Predicate<E>> findFunction, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) contains A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <T1,
T2> void invoke
(Consumer<Runnable> runFunction, T1 captureVal1, T2 captureVal2, Invokers.Params2.ICallback<T1, T2> lambdaFunc) invoke A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <T1> void
invoke
(Consumer<Runnable> runFunction, T1 captureVal1, Invokers.Params1.ICallback<T1> lambdaFunc) invoke A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.static <T1,
T2, T3, T4>
Runnableinvoker
(T1 val1, T2 val2, T3 val3, T4 val4, Invokers.Params4.ICallback<T1, T2, T3, T4> invoker) static <T1,
T2, T3> Runnable invoker
(T1 val1, T2 val2, T3 val3, Invokers.Params3.ICallback<T1, T2, T3> invoker) static <T1,
T2> Runnable invoker
(T1 val1, T2 val2, Invokers.Params2.ICallback<T1, T2> invoker) static <T1> Runnable
invoker
(T1 val1, Invokers.Params1.ICallback<T1> invoker) static <E,
T1, T2, T3>
Predicate<E>predicate
(T1 val1, T2 val2, T3 val3, Predicates.Params3.ICallback<E, T1, T2, T3> predicate) static <E,
T1, T2> Predicate<E> predicate
(T1 val1, T2 val2, Predicates.Params2.ICallback<E, T1, T2> predicate) static <E,
T1> Predicate<E> predicate
(T1 val1, Predicates.Params1.ICallback<E, T1> predicate)
-
Constructor Details
-
Lambda
public Lambda()
-
-
Method Details
-
predicate
-
predicate
public static <E,T1, Predicate<E> predicateT2> (T1 val1, T2 val2, Predicates.Params2.ICallback<E, T1, T2> predicate) -
predicate
public static <E,T1, Predicate<E> predicateT2, T3> (T1 val1, T2 val2, T3 val3, Predicates.Params3.ICallback<E, T1, T2, T3> predicate) -
comparator
public static <E,T1> Comparator<E> comparator(T1 val1, Comparators.Params1.ICallback<E, T1> comparator) -
comparator
public static <E,T1, Comparator<E> comparatorT2> (T1 val1, T2 val2, Comparators.Params2.ICallback<E, T1, T2> comparator) -
consumer
-
consumer
public static <E,T1, Consumer<E> consumerT2> (T1 val1, T2 val2, Consumers.Params2.ICallback<E, T1, T2> consumer) -
consumer
public static <E,T1, Consumer<E> consumerT2, T3> (T1 val1, T2 val2, T3 val3, Consumers.Params3.ICallback<E, T1, T2, T3> consumer) -
consumer
public static <E,T1, Consumer<E> consumerT2, T3, T4> (T1 val1, T2 val2, T3 val3, T4 val4, Consumers.Params4.ICallback<E, T1, T2, T3, T4> consumer) -
consumer
public static <E,T1, Consumer<E> consumerT2, T3, T4, T5> (T1 val1, T2 val2, T3 val3, T4 val4, T5 val5, Consumers.Params5.ICallback<E, T1, T2, T3, T4, T5> consumer) -
invoker
-
invoker
public static <T1,T2> Runnable invoker(T1 val1, T2 val2, Invokers.Params2.ICallback<T1, T2> invoker) -
invoker
public static <T1,T2, Runnable invokerT3> (T1 val1, T2 val2, T3 val3, Invokers.Params3.ICallback<T1, T2, T3> invoker) -
invoker
public static <T1,T2, Runnable invokerT3, T4> (T1 val1, T2 val2, T3 val3, T4 val4, Invokers.Params4.ICallback<T1, T2, T3, T4> invoker) -
capture
-
capture
public static <T1,T2> void capture(T1 val1, T2 val2, Stacks.Params2.ICallback<T1, T2> captureConsumer) -
capture
public static <T1,T2, void captureT3> (T1 val1, T2 val2, T3 val3, Stacks.Params3.ICallback<T1, T2, T3> captureConsumer) -
capture
public static <T1,T2, void captureT3, T4> (T1 val1, T2 val2, T3 val3, T4 val4, Stacks.Params4.ICallback<T1, T2, T3, T4> captureConsumer) -
capture
public static <T1,T2, void captureT3, T4, T5> (T1 val1, T2 val2, T3 val3, T4 val4, T5 val5, Stacks.Params5.ICallback<T1, T2, T3, T4, T5> captureConsumer) -
capture
public static <T1,T2, void captureT3, T4, T5, T6> (T1 val1, T2 val2, T3 val3, T4 val4, T5 val5, T6 val6, Stacks.Params6.ICallback<T1, T2, T3, T4, T5, T6> captureConsumer) -
forEach
public static <E,T1> void forEach(Consumer<Consumer<E>> forEachFunction, T1 captureVal1, Consumers.Params1.ICallback<E, T1> lambdaFunc) forEach A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied forEach function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the consumer() function above.
-
forEach
public static <E,T1, void forEachT2> (Consumer<Consumer<E>> forEachFunction, T1 captureVal1, T2 captureVal2, Consumers.Params2.ICallback<E, T1, T2> lambdaFunc) forEach A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied forEach function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the consumer() function above.
-
forEachFrom
public static <E,T1> void forEachFrom(BiConsumer<List<E>, Consumer<E>> forEachFunction, List<E> from, T1 captureVal1, Consumers.Params1.ICallback<E, T1> lambdaFunc) forEachFrom (List, 1-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied forEach function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the consumer() function above.
-
forEachFrom
public static <E,T1, void forEachFromT2> (BiConsumer<List<E>, Consumer<E>> forEachFunction, List<E> from, T1 captureVal1, T2 captureVal2, Consumers.Params2.ICallback<E, T1, T2> lambdaFunc) forEachFrom (List, 2-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied forEach function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the consumer() function above.
-
forEachFrom
public static <E,F, void forEachFromT1> (BiConsumer<F, Consumer<E>> forEachFunction, F from, T1 captureVal1, Consumers.Params1.ICallback<E, T1> lambdaFunc) forEachFrom (Node, 1-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied forEach function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the consumer() function above.
-
forEachFrom
public static <E,F, void forEachFromT1, T2> (BiConsumer<F, Consumer<E>> forEachFunction, F from, T1 captureVal1, T2 captureVal2, Consumers.Params2.ICallback<E, T1, T2> lambdaFunc) forEachFrom (Node, 2-param) A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied forEach function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the consumer() function above.
-
find
public static <E,T1, R findR> (Function<Predicate<E>, R> findFunction, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) find A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied find function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the predicate() function above.
-
indexOf
public static <E,T1> int indexOf(IntSupplierFunction<Predicate<E>> findFunction, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) contains A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied find function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the predicate() function above.
-
contains
public static <E,T1> boolean contains(Predicate<Predicate<E>> findFunction, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) contains A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied find function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the predicate() function above.
-
containsFrom
public static <E,F extends Iterable<E>, boolean containsFromT1> (BiPredicate<F, Predicate<E>> findFunction, F from, T1 captureVal1, Predicates.Params1.ICallback<E, T1> lambdaFunc) containsFrom A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied find function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the predicate() function above.
-
invoke
public static <T1> void invoke(Consumer<Runnable> runFunction, T1 captureVal1, Invokers.Params1.ICallback<T1> lambdaFunc) invoke A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied invoke function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the invoker() function above.
-
invoke
public static <T1,T2> void invoke(Consumer<Runnable> runFunction, T1 captureVal1, T2 captureVal2, Invokers.Params2.ICallback<T1, T2> lambdaFunc) invoke A way to call in-place lambdas with captured variables while avoiding Garbage-Collection.Uses lambda.Stacks to allocate a new lambda function and store the supplied variables in a pool. It then invokes the supplied invoke function, and calls release() on all pooled items when it finishes.
This removes the need to call release() explicitly. Eg. when using the invoker() function above.
-