public class LongFunctions extends Object
DoubleFunctions
except operating on longs.
For aliasing see longFunctions
.
Modifier and Type | Field and Description |
---|---|
static LongFunction |
abs
Function that returns Math.abs(a) == (a < 0) ? -a : a.
|
static LongLongFunction |
and
Function that returns a & b.
|
static LongLongFunction |
compare
Function that returns a < b ? -1 : a > b ? 1 : 0.
|
static LongFunction |
dec
Function that returns a--.
|
static LongLongFunction |
div
Function that returns a / b.
|
static LongLongFunction |
divNeg
Function that returns -(a / b).
|
static LongLongFunction |
equals
Function that returns a == b ? 1 : 0.
|
static LongFunction |
factorial
Function that returns (long) Arithmetic.factorial(a).
|
static LongFunction |
identity
Function that returns its argument.
|
static LongFunction |
inc
Function that returns a++.
|
static LongLongProcedure |
isEqual
Function that returns a == b.
|
static LongLongProcedure |
isGreater
Function that returns a > b.
|
static LongLongProcedure |
isLess
Function that returns a < b.
|
static LongFunctions |
longFunctions
Little trick to allow for "aliasing", that is, renaming this class.
|
static LongLongFunction |
max
Function that returns Math.max(a,b).
|
static LongLongFunction |
min
Function that returns Math.min(a,b).
|
static LongLongFunction |
minus
Function that returns a - b.
|
static LongLongFunction |
mod
Function that returns a % b.
|
static LongLongFunction |
mult
Function that returns a * b.
|
static LongLongFunction |
multNeg
Function that returns -(a * b).
|
static LongLongFunction |
multSquare
Function that returns a * b^2.
|
static LongFunction |
neg
Function that returns -a.
|
static LongFunction |
not
Function that returns ~a.
|
static LongLongFunction |
or
Function that returns a | b.
|
static LongLongFunction |
plus
Function that returns a + b.
|
static LongLongFunction |
plusAbs
Function that returns Math.abs(a) + Math.abs(b).
|
static LongLongFunction |
pow
Function that returns (long) Math.pow(a,b).
|
static LongLongFunction |
shiftLeft
Function that returns a << b.
|
static LongLongFunction |
shiftRightSigned
Function that returns a >> b.
|
static LongLongFunction |
shiftRightUnsigned
Function that returns a >>> b.
|
static LongFunction |
sign
Function that returns a < 0 ? -1 : a > 0 ? 1 : 0.
|
static LongFunction |
square
Function that returns a * a.
|
static LongLongFunction |
xor
Function that returns a ^ b.
|
Modifier and Type | Method and Description |
---|---|
static LongFunction |
and(long b)
Constructs a function that returns a & b.
|
static LongFunction |
between(long from,
long to)
Constructs a function that returns (from<=a && a<=to) ? 1 : 0.
|
static LongFunction |
bindArg1(LongLongFunction function,
long c)
Constructs a unary function from a binary function with the first operand
(argument) fixed to the given constant c.
|
static LongFunction |
bindArg2(LongLongFunction function,
long c)
Constructs a unary function from a binary function with the second
operand (argument) fixed to the given constant c.
|
static LongFunction |
chain(LongFunction g,
LongFunction h)
Constructs the function g( h(a) ).
|
static LongLongFunction |
chain(LongFunction g,
LongLongFunction h)
Constructs the function g( h(a,b) ).
|
static LongLongFunction |
chain(LongLongFunction f,
LongFunction g,
LongFunction h)
Constructs the function f( g(a), h(b) ).
|
static LongFunction |
compare(long b)
Constructs a function that returns a < b ? -1 : a > b ? 1 : 0.
|
static LongFunction |
constant(long c)
Constructs a function that returns the constant c.
|
static LongFunction |
div(long b)
Constructs a function that returns a / b.
|
static LongFunction |
equals(long b)
Constructs a function that returns a == b ? 1 : 0.
|
static LongProcedure |
isBetween(long from,
long to)
Constructs a function that returns from<=a && a<=to.
|
static LongProcedure |
isEqual(long b)
Constructs a function that returns a == b.
|
static LongProcedure |
isGreater(long b)
Constructs a function that returns a > b.
|
static LongProcedure |
isLess(long b)
Constructs a function that returns a < b.
|
static LongFunction |
max(long b)
Constructs a function that returns Math.max(a,b).
|
static LongFunction |
min(long b)
Constructs a function that returns Math.min(a,b).
|
static LongFunction |
minus(long b)
Constructs a function that returns a - b.
|
static LongLongFunction |
minusMult(long constant)
Constructs a function that returns a - b*constant.
|
static LongFunction |
mod(long b)
Constructs a function that returns a % b.
|
static LongFunction |
mult(long b)
Constructs a function that returns a * b.
|
static LongLongFunction |
multSecond(long constant)
Constructs a function that returns b*constant.
|
static LongFunction |
or(long b)
Constructs a function that returns a | b.
|
static LongFunction |
plus(long b)
Constructs a function that returns a + b.
|
static LongLongFunction |
plusMultFirst(long constant)
Constructs a function that returns a * constant + b.
|
static LongLongFunction |
plusMultSecond(long constant)
Constructs a function that returns a + b*constant.
|
static LongFunction |
pow(long b)
Constructs a function that returns (long) Math.pow(a,b).
|
static LongFunction |
random()
Constructs a function that returns a 32 bit uniformly distributed random
number in the closed longerval [Long.MIN_VALUE,Long.MAX_VALUE]
(including Long.MIN_VALUE and Long.MAX_VALUE).
|
static LongFunction |
shiftLeft(long b)
Constructs a function that returns a << b.
|
static LongFunction |
shiftRightSigned(long b)
Constructs a function that returns a >> b.
|
static LongFunction |
shiftRightUnsigned(long b)
Constructs a function that returns a >>> b.
|
static LongLongFunction |
swapArgs(LongLongFunction function)
Constructs a function that returns function.apply(b,a), i.e.
|
static LongFunction |
xor(long b)
Constructs a function that returns a | b.
|
public static final LongFunctions longFunctions
LongFunctions.chain(LongFunctions.plus,LongFunctions.mult(3),LongFunctions.chain(LongFunctions.square,LongFunctions.div(2)));
is a bit awkward, to say the least. Using the aliasing you can instead write
LongFunctions F = LongFunctions.longFunctions;
F.chain(F.plus,F.mult(3),F.chain(F.square,F.div(2)));
public static final LongFunction abs
public static final LongFunction dec
public static final LongFunction factorial
public static final LongFunction identity
public static final LongFunction inc
public static final LongFunction neg
public static final LongFunction not
public static final LongFunction sign
public static final LongFunction square
public static final LongLongFunction and
public static final LongLongFunction compare
public static final LongLongFunction div
public static final LongLongFunction divNeg
public static final LongLongFunction equals
public static final LongLongProcedure isEqual
public static final LongLongProcedure isLess
public static final LongLongProcedure isGreater
public static final LongLongFunction max
public static final LongLongFunction min
public static final LongLongFunction minus
public static final LongLongFunction mod
public static final LongLongFunction mult
public static final LongLongFunction multNeg
public static final LongLongFunction multSquare
public static final LongLongFunction or
public static final LongLongFunction plus
public static final LongLongFunction plusAbs
public static final LongLongFunction pow
public static final LongLongFunction shiftLeft
public static final LongLongFunction shiftRightSigned
public static final LongLongFunction shiftRightUnsigned
public static final LongLongFunction xor
public static LongFunction and(long b)
public static LongFunction between(long from, long to)
public static LongFunction bindArg1(LongLongFunction function, long c)
function
- a binary function taking operands in the form
function.apply(c,var).public static LongFunction bindArg2(LongLongFunction function, long c)
function
- a binary function taking operands in the form
function.apply(var,c).public static LongFunction chain(LongFunction g, LongFunction h)
g
- a unary function.h
- a unary function.public static LongLongFunction chain(LongFunction g, LongLongFunction h)
g
- a unary function.h
- a binary function.public static LongLongFunction chain(LongLongFunction f, LongFunction g, LongFunction h)
f
- a binary function.g
- a unary function.h
- a unary function.public static LongFunction compare(long b)
public static LongFunction constant(long c)
public static LongFunction div(long b)
public static LongFunction equals(long b)
public static LongProcedure isBetween(long from, long to)
public static LongProcedure isEqual(long b)
public static LongProcedure isGreater(long b)
public static LongProcedure isLess(long b)
public static LongFunction max(long b)
public static LongFunction min(long b)
public static LongFunction minus(long b)
public static LongLongFunction minusMult(long constant)
public static LongFunction mod(long b)
public static LongFunction mult(long b)
public static LongFunction or(long b)
public static LongFunction plus(long b)
public static LongLongFunction multSecond(long constant)
public static LongFunction pow(long b)
public static LongLongFunction plusMultSecond(long constant)
public static LongLongFunction plusMultFirst(long constant)
public static LongFunction random()
DoubleMersenneTwister
and is
seeded with the current time.
Note that any random engine derived from
DoubleRandomEngine
and any random
distribution derived from
AbstractDoubleDistribution
are function
objects, because they implement the proper longerfaces. Thus, if you are
not happy with the default, just pass your favourite random generator to
function evaluating methods.
public static LongFunction shiftLeft(long b)
public static LongFunction shiftRightSigned(long b)
public static LongFunction shiftRightUnsigned(long b)
public static LongLongFunction swapArgs(LongLongFunction function)
function
- a function taking operands in the form
function.apply(a,b).public static LongFunction xor(long b)
Jump to the Parallel Colt Homepage