Class JxnF2
- java.lang.Object
-
- JxnFunction
-
- JxnF2
-
- All Implemented Interfaces:
Comparator,BiConsumer,BiFunction,BinaryOperator,BiPredicate,DoubleBinaryOperator,IntBinaryOperator,LongBinaryOperator,ObjDoubleConsumer,ObjIntConsumer,ObjLongConsumer,ToDoubleBiFunction,ToIntBiFunction,ToLongBiFunction
public class JxnF2 extends JxnFunction implements Comparator, BiPredicate, BiFunction, ToIntBiFunction, ToLongBiFunction, ToDoubleBiFunction, BinaryOperator, IntBinaryOperator, LongBinaryOperator, DoubleBinaryOperator, BiConsumer, ObjIntConsumer, ObjLongConsumer, ObjDoubleConsumer
The classesJxnF,JxnF2,JxnI,JxnLandJxnDtogether implement all interfaces of packagejava.util.functionforjava.util.stream. This allows to explore and use java → aggregate operations interactively from JXN.JxnFimplements all single or zero parameter methods,JxnF2all double parameter methods andJxnI,JxnLandJxnDmethods incompatible withPredicate.- See Also:
- AggregateOperations_Demo.jxn
-
-
Constructor Summary
Constructors Constructor Description JxnF2(JxnFunction f)ConstructsJxnF2from an already definedJxnFunction f.JxnF2(KmgFormelInterpreter fi, String cmd)Calls constructorJxnFunction( fi, cmd ).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(Object t, double value)voidaccept(Object t, int value)voidaccept(Object t, long value)voidaccept(Object t, Object u)Objectapply(Object t, Object u)ImplementsBiFunction,BinaryOperatorforStream.reduce(…),Collector.of(…),Collectors.toMap(…),.toConcurrentMap(…),.reducing(…).doubleapplyAsDouble(double left, double right)doubleapplyAsDouble(Object t, Object u)ImplementsToDoubleBiFunction.intapplyAsInt(int left, int right)intapplyAsInt(Object t, Object u)ImplementsToIntBiFunction.longapplyAsLong(long left, long right)longapplyAsLong(Object t, Object u)ImplementsToLongBiFunction.intcompare(Object o1, Object o2)ImplementsComparator.protected Objectexec(Object[] args)Mapsargsto$_and the names passed to the constructor viaparameterNames.protected Objectexecute(Object o1, Object o2)booleantest(Object t, Object u)ImplementsBiPredicate.-
Methods inherited from interface java.util.function.BiConsumer
andThen
-
Methods inherited from interface java.util.function.BiFunction
andThen
-
Methods inherited from interface java.util.function.BinaryOperator
-
Methods inherited from interface java.util.function.BiPredicate
and, negate, or
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from class JxnFunction
getArityLenience, getDebug, getShowConditional, getShowInternalResults, setArityLenience, setDebug, setShowConditional, setShowInternalResults, toString
-
-
-
-
Constructor Detail
-
JxnF2
public JxnF2(JxnFunction f)
ConstructsJxnF2from an already definedJxnFunction f.
Can be used, iffis defined using jxn special commands:#function f ... #endfunction
Example:#function reverse( s1, s2 ) s2.compareTo( s1 ) ! reverse order #endfunction sa = { "DEF", "abc", "XYZ", "ghi", "___" };Arrays.sort(sa); sa = { DEF, XYZ, ___, abc, ghi } (java.lang.String[5])Arrays.sort( sa, @JxnF2( reverse ) ); sa = { ghi, abc, ___, XYZ, DEF } (java.lang.String[5])
-
JxnF2
public JxnF2(KmgFormelInterpreter fi, String cmd)
Calls constructorJxnFunction( fi, cmd ).
Example:sa = { "DEF", "abc", "XYZ", "ghi", "___" };Arrays.sort(sa); sa = { DEF, XYZ, ___, abc, ghi } (java.lang.String[5])Arrays.sort( sa, @JxnF2( $this, "( s1, s2 ) -> s1.compareToIgnoreCases2" ) ); sa = { ___, abc, DEF, ghi, XYZ } (java.lang.String[5])- Parameters:
cmd- statement_sequence (one or more statements separated by';') or #filename[.jxn]. (Note: jxn does not support{…}blocks as possible in java → lambda expressions)
-
-
Method Detail
-
exec
protected Object exec(Object[] args)
Description copied from class:JxnFunctionMapsargsto$_and the names passed to the constructor viaparameterNames.
Example:
fn = @JxnFunction( … ) !calls a constructor to create a function instancefn
:
fn( arg1, arg2, ..., argN ) !⇒ jxn internally callsfn.exec( { arg1, arg2, ..., argN } )- Overrides:
execin classJxnFunction
-
compare
public int compare(Object o1, Object o2)
ImplementsComparator.- Specified by:
comparein interfaceComparator
-
test
public boolean test(Object t, Object u)
ImplementsBiPredicate.- Specified by:
testin interfaceBiPredicate
-
apply
public Object apply(Object t, Object u)
ImplementsBiFunction,BinaryOperatorforStream.reduce(…),Collector.of(…),Collectors.toMap(…),.toConcurrentMap(…),.reducing(…).- Specified by:
applyin interfaceBiFunction
-
applyAsInt
public int applyAsInt(Object t, Object u)
ImplementsToIntBiFunction.- Specified by:
applyAsIntin interfaceToIntBiFunction
-
applyAsLong
public long applyAsLong(Object t, Object u)
ImplementsToLongBiFunction.- Specified by:
applyAsLongin interfaceToLongBiFunction
-
applyAsDouble
public double applyAsDouble(Object t, Object u)
ImplementsToDoubleBiFunction.- Specified by:
applyAsDoublein interfaceToDoubleBiFunction
-
applyAsInt
public int applyAsInt(int left, int right)- Specified by:
applyAsIntin interfaceIntBinaryOperator
-
applyAsLong
public long applyAsLong(long left, long right)- Specified by:
applyAsLongin interfaceLongBinaryOperator
-
applyAsDouble
public double applyAsDouble(double left, double right)- Specified by:
applyAsDoublein interfaceDoubleBinaryOperator
-
accept
public void accept(Object t, Object u)
ImplementsBiConsumerforStream<T>.collect(…),IntStream.collect(…),LongStream.collect(…),DoubleStream.collect(…),Collector.of(…).- Specified by:
acceptin interfaceBiConsumer
-
accept
public void accept(Object t, int value)
- Specified by:
acceptin interfaceObjIntConsumer
-
accept
public void accept(Object t, long value)
- Specified by:
acceptin interfaceObjLongConsumer
-
accept
public void accept(Object t, double value)
- Specified by:
acceptin interfaceObjDoubleConsumer
-
-