public class IntFunctions extends Object
Functions
except operating on integers.
For aliasing see intFunctions
.
Modifier and Type | Field and Description |
---|---|
static IntFunction |
abs
Function that returns Math.abs(a) == (a < 0) ? -a : a.
|
static IntIntFunction |
and
Function that returns a & b.
|
static IntIntFunction |
compare
Function that returns a < b ? -1 : a > b ? 1 : 0.
|
static IntFunction |
dec
Function that returns a--.
|
static IntIntFunction |
div
Function that returns a / b.
|
static IntIntFunction |
equals
Function that returns a == b ? 1 : 0.
|
static IntFunction |
factorial
Function that returns (int) Arithmetic.factorial(a).
|
static IntFunction |
identity
Function that returns its argument.
|
static IntFunction |
inc
Function that returns a++.
|
static IntFunctions |
intFunctions
Little trick to allow for "aliasing", that is, renaming this class.
|
static IntIntProcedure |
isEqual
Function that returns a == b.
|
static IntIntProcedure |
isGreater
Function that returns a > b.
|
static IntIntProcedure |
isLess
Function that returns a < b.
|
static IntIntFunction |
max
Function that returns Math.max(a,b).
|
static IntIntFunction |
min
Function that returns Math.min(a,b).
|
static IntIntFunction |
minus
Function that returns a - b.
|
static IntIntFunction |
mod
Function that returns a % b.
|
static IntIntFunction |
mult
Function that returns a * b.
|
static IntFunction |
neg
Function that returns -a.
|
static IntFunction |
not
Function that returns ~a.
|
static IntIntFunction |
or
Function that returns a | b.
|
static IntIntFunction |
plus
Function that returns a + b.
|
static IntIntFunction |
pow
Function that returns (int) Math.pow(a,b).
|
static IntIntFunction |
shiftLeft
Function that returns a << b.
|
static IntIntFunction |
shiftRightSigned
Function that returns a >> b.
|
static IntIntFunction |
shiftRightUnsigned
Function that returns a >>> b.
|
static IntFunction |
sign
Function that returns a < 0 ? -1 : a > 0 ? 1 : 0.
|
static IntFunction |
square
Function that returns a * a.
|
static IntIntFunction |
xor
Function that returns a ^ b.
|
Modifier and Type | Method and Description |
---|---|
static IntFunction |
and(int b)
Constructs a function that returns a & b.
|
static IntFunction |
between(int from,
int to)
Constructs a function that returns (from<=a && a<=to) ? 1 : 0.
|
static IntFunction |
bindArg1(IntIntFunction function,
int c)
Constructs a unary function from a binary function with the first operand (argument) fixed to the given constant c.
|
static IntFunction |
bindArg2(IntIntFunction function,
int c)
Constructs a unary function from a binary function with the second operand (argument) fixed to the given constant c.
|
static IntFunction |
chain(IntFunction g,
IntFunction h)
Constructs the function g( h(a) ).
|
static IntIntFunction |
chain(IntFunction g,
IntIntFunction h)
Constructs the function g( h(a,b) ).
|
static IntIntFunction |
chain(IntIntFunction f,
IntFunction g,
IntFunction h)
Constructs the function f( g(a), h(b) ).
|
static IntFunction |
compare(int b)
Constructs a function that returns a < b ? -1 : a > b ? 1 : 0.
|
static IntFunction |
constant(int c)
Constructs a function that returns the constant c.
|
static IntFunction |
div(int b)
Constructs a function that returns a / b.
|
static IntFunction |
equals(int b)
Constructs a function that returns a == b ? 1 : 0.
|
static IntProcedure |
isBetween(int from,
int to)
Constructs a function that returns from<=a && a<=to.
|
static IntProcedure |
isEqual(int b)
Constructs a function that returns a == b.
|
static IntProcedure |
isGreater(int b)
Constructs a function that returns a > b.
|
static IntProcedure |
isLess(int b)
Constructs a function that returns a < b.
|
static IntFunction |
max(int b)
Constructs a function that returns Math.max(a,b).
|
static IntFunction |
min(int b)
Constructs a function that returns Math.min(a,b).
|
static IntFunction |
minus(int b)
Constructs a function that returns a - b.
|
static IntFunction |
mod(int b)
Constructs a function that returns a % b.
|
static IntFunction |
mult(int b)
Constructs a function that returns a * b.
|
static IntFunction |
or(int b)
Constructs a function that returns a | b.
|
static IntFunction |
plus(int b)
Constructs a function that returns a + b.
|
static IntFunction |
pow(int b)
Constructs a function that returns (int) Math.pow(a,b).
|
static IntFunction |
random()
Constructs a function that returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE).
|
static IntFunction |
shiftLeft(int b)
Constructs a function that returns a << b.
|
static IntFunction |
shiftRightSigned(int b)
Constructs a function that returns a >> b.
|
static IntFunction |
shiftRightUnsigned(int b)
Constructs a function that returns a >>> b.
|
static IntIntFunction |
swapArgs(IntIntFunction function)
Constructs a function that returns function.apply(b,a), i.e.
|
static IntFunction |
xor(int b)
Constructs a function that returns a | b.
|
public static final IntFunctions intFunctions
IntFunctions.chain(IntFunctions.plus,IntFunctions.mult(3),IntFunctions.chain(IntFunctions.square,IntFunctions.div(2)));
is a bit awkward, to say the least. Using the aliasing you can instead write
IntFunctions F = IntFunctions.intFunctions;
F.chain(F.plus,F.mult(3),F.chain(F.square,F.div(2)));
public static final IntFunction abs
public static final IntFunction dec
public static final IntFunction factorial
public static final IntFunction identity
public static final IntFunction inc
public static final IntFunction neg
public static final IntFunction not
public static final IntFunction sign
public static final IntFunction square
public static final IntIntFunction and
public static final IntIntFunction compare
public static final IntIntFunction div
public static final IntIntFunction equals
public static final IntIntProcedure isEqual
public static final IntIntProcedure isLess
public static final IntIntProcedure isGreater
public static final IntIntFunction max
public static final IntIntFunction min
public static final IntIntFunction minus
public static final IntIntFunction mod
public static final IntIntFunction mult
public static final IntIntFunction or
public static final IntIntFunction plus
public static final IntIntFunction pow
public static final IntIntFunction shiftLeft
public static final IntIntFunction shiftRightSigned
public static final IntIntFunction shiftRightUnsigned
public static final IntIntFunction xor
public static IntFunction and(int b)
public static IntFunction between(int from, int to)
public static IntFunction bindArg1(IntIntFunction function, int c)
function
- a binary function taking operands in the form function.apply(c,var).public static IntFunction bindArg2(IntIntFunction function, int c)
function
- a binary function taking operands in the form function.apply(var,c).public static IntFunction chain(IntFunction g, IntFunction h)
g
- a unary function.h
- a unary function.public static IntIntFunction chain(IntFunction g, IntIntFunction h)
g
- a unary function.h
- a binary function.public static IntIntFunction chain(IntIntFunction f, IntFunction g, IntFunction h)
f
- a binary function.g
- a unary function.h
- a unary function.public static IntFunction compare(int b)
public static IntFunction constant(int c)
public static IntFunction div(int b)
public static IntFunction equals(int b)
public static IntProcedure isBetween(int from, int to)
public static IntProcedure isEqual(int b)
public static IntProcedure isGreater(int b)
public static IntProcedure isLess(int b)
public static IntFunction max(int b)
public static IntFunction min(int b)
public static IntFunction minus(int b)
public static IntFunction mod(int b)
public static IntFunction mult(int b)
public static IntFunction or(int b)
public static IntFunction plus(int b)
public static IntFunction pow(int b)
public static IntFunction random()
MersenneTwister
and is seeded with the current time.
Note that any random engine derived from RandomEngine
and any random distribution derived from AbstractDistribution
are function objects, because they implement the proper interfaces.
Thus, if you are not happy with the default, just pass your favourite random generator to function evaluating methods.
public static IntFunction shiftLeft(int b)
public static IntFunction shiftRightSigned(int b)
public static IntFunction shiftRightUnsigned(int b)
public static IntIntFunction swapArgs(IntIntFunction function)
function
- a function taking operands in the form function.apply(a,b).public static IntFunction xor(int b)
Jas4pp 1.5 © Java Analysis Studio for Particle Physics