public final class Enumerator<A>
extends java.lang.Object
plus
, otherwise a default is implemented using
the given successor/predecessor implementations.
For any enumerator e, the following laws must satisfy:
forall a. e.successor(a).forall(\t -> e.predecessor(t).forall(\z -> z == a))
forall a. e.predecessor(a).forall(\t -> e.successor(t).forall(\z -> z == a))
e.max().forall(\t -> e.successor(t).isNone)
e.min().forall(\t -> e.predecessor(t).isNone)
forall a n. e.plus(a, 0) == Some(a)
forall a n | n > 0. e.plus(a, n) == e.plus(a, n - 1)
forall a n | n < 0. e.plus(a, n) == e.plus(a, n + 1)
Modifier and Type | Field and Description |
---|---|
static Enumerator<java.math.BigDecimal> |
bigdecimalEnumerator
An enumerator for
BigDecimal . |
static Enumerator<java.math.BigInteger> |
bigintEnumerator
An enumerator for
BigInteger . |
static Enumerator<java.lang.Boolean> |
booleanEnumerator
An enumerator for
boolean . |
static Enumerator<java.lang.Byte> |
byteEnumerator
An enumerator for
byte . |
static Enumerator<java.lang.Character> |
charEnumerator
An enumerator for
char . |
static Enumerator<java.lang.Double> |
doubleEnumerator
An enumerator for
double . |
static Enumerator<java.lang.Float> |
floatEnumerator
An enumerator for
float . |
static Enumerator<java.lang.Integer> |
intEnumerator
An enumerator for
int . |
static Enumerator<java.lang.Long> |
longEnumerator
An enumerator for
long . |
static Enumerator<Natural> |
naturalEnumerator
An enumerator for
Natural |
static Enumerator<Ordering> |
orderingEnumerator
An enumerator for
Ordering . |
static Enumerator<java.lang.Short> |
shortEnumerator
An enumerator for
short . |
Modifier and Type | Method and Description |
---|---|
static <A> Enumerator<A> |
enumerator(F<A,Option<A>> successor,
F<A,Option<A>> predecessor,
Option<A> max,
Option<A> min,
Ord<A> order)
Construct an enumerator.
|
static <A> Enumerator<A> |
enumerator(F<A,Option<A>> successor,
F<A,Option<A>> predecessor,
Option<A> max,
Option<A> min,
Ord<A> order,
F<A,F<java.lang.Long,Option<A>>> plus)
Construct an enumerator.
|
Option<A> |
max()
Returns the maximum value for this enumerator if there is one.
|
Option<A> |
min()
Returns the minimum value for this enumerator if there is one.
|
Ord<A> |
order()
Returns the ordering for the enumerator.
|
F<A,F<java.lang.Long,Option<A>>> |
plus()
Returns a function that moves a value along the enumerator a given number of times.
|
F<java.lang.Long,Option<A>> |
plus(A a)
Returns a function that moves a value along the enumerator a given number of times.
|
Option<A> |
plus(A a,
long l)
Moves a value along the enumerator a given number of times.
|
F<A,Option<A>> |
plus(long l)
Returns a function that moves a value along the enumerator a given number of times.
|
F<A,Option<A>> |
predecessor()
Returns the potential predecessor of a value for this enumerator in curried form.
|
Option<A> |
predecessor(A a)
Returns the potential predecessor of a value for this enumerator.
|
Enumerator<A> |
setMax(Option<A> max)
Create a new enumerator with the given maximum value.
|
Enumerator<A> |
setMin(Option<A> min)
Create a new enumerator with the given minimum value.
|
F<A,Option<A>> |
successor()
Returns the potential successor of a value for this enumerator in curried form.
|
Option<A> |
successor(A a)
Returns the potential successor of a value for this enumerator.
|
Stream<A> |
toStream(A a)
Returns a stream of the values from this enumerator, starting at the given value, counting up.
|
<B> Enumerator<B> |
xmap(F<A,B> f,
F<B,A> g)
Invariant functor map over this enumerator.
|
public static final Enumerator<java.lang.Boolean> booleanEnumerator
boolean
.public static final Enumerator<java.lang.Byte> byteEnumerator
byte
.public static final Enumerator<java.lang.Character> charEnumerator
char
.public static final Enumerator<java.lang.Double> doubleEnumerator
double
.public static final Enumerator<java.lang.Float> floatEnumerator
float
.public static final Enumerator<java.lang.Integer> intEnumerator
int
.public static final Enumerator<java.math.BigInteger> bigintEnumerator
BigInteger
.public static final Enumerator<java.math.BigDecimal> bigdecimalEnumerator
BigDecimal
.public static final Enumerator<java.lang.Long> longEnumerator
long
.public static final Enumerator<java.lang.Short> shortEnumerator
short
.public static final Enumerator<Ordering> orderingEnumerator
Ordering
.public static final Enumerator<Natural> naturalEnumerator
Natural
public F<A,Option<A>> successor()
public Option<A> successor(A a)
a
- The value to return the successor of.public F<A,Option<A>> predecessor()
public Option<A> predecessor(A a)
a
- The value to return the predecessor of.public Option<A> max()
public Option<A> min()
public F<A,F<java.lang.Long,Option<A>>> plus()
public F<java.lang.Long,Option<A>> plus(A a)
a
- The value to begin moving along from.public F<A,Option<A>> plus(long l)
l
- The number of times to move along the enumerator.public Option<A> plus(A a, long l)
a
- The value to begin moving along from.l
- The number of times to move along the enumerator.public Ord<A> order()
public <B> Enumerator<B> xmap(F<A,B> f, F<B,A> g)
f
- The covariant map.g
- The contra-variant map.public Stream<A> toStream(A a)
a
- A value at which to begin the stream.public Enumerator<A> setMin(Option<A> min)
min
- A minimum value.public Enumerator<A> setMax(Option<A> max)
max
- A maximum value.public static <A> Enumerator<A> enumerator(F<A,Option<A>> successor, F<A,Option<A>> predecessor, Option<A> max, Option<A> min, Ord<A> order, F<A,F<java.lang.Long,Option<A>>> plus)
successor
- The successor function.predecessor
- The predecessor function.max
- The potential maximum value.min
- The potential minimum value.order
- The ordering for the type.plus
- The function to move the enumeration a given number of times. This may be supplied for a performance
enhancement for certain types.public static <A> Enumerator<A> enumerator(F<A,Option<A>> successor, F<A,Option<A>> predecessor, Option<A> max, Option<A> min, Ord<A> order)
plus
function is derived from the successor
and
predecessor
.successor
- The successor function.predecessor
- The predecessor function.max
- The potential maximum value.min
- The potential minimum value.order
- The ordering for the type.