Class Enumerator<A>
java.lang.Object
fj.data.Enumerator<A>
Abstracts over a type that may have a successor and/or predecessor value. This implies ordering for that type. A user
may construct an enumerator with an optimised version for
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)
- Version:
- %build.number%
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Enumerator<BigDecimal> An enumerator forBigDecimal.static final Enumerator<BigInteger> An enumerator forBigInteger.static final Enumerator<Boolean> An enumerator forboolean.static final Enumerator<Byte> An enumerator forbyte.static final Enumerator<Character> An enumerator forchar.static final Enumerator<Double> An enumerator fordouble.static final Enumerator<Float> An enumerator forfloat.static final Enumerator<Integer> An enumerator forint.static final Enumerator<Long> An enumerator forlong.static final Enumerator<Natural> An enumerator forNaturalstatic final Enumerator<Ordering> An enumerator forOrdering.static final Enumerator<Short> An enumerator forshort. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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<Long, Option<A>>> plus) Construct an enumerator.max()Returns the maximum value for this enumerator if there is one.min()Returns the minimum value for this enumerator if there is one.order()Returns the ordering for the enumerator.plus()Returns a function that moves a value along the enumerator a given number of times.plus(long l) Returns a function that moves a value along the enumerator a given number of times.Returns a function that moves a value along the enumerator a given number of times.Moves a value along the enumerator a given number of times.Returns the potential predecessor of a value for this enumerator in curried form.predecessor(A a) Returns the potential predecessor of a value for this enumerator.Create a new enumerator with the given maximum value.Create a new enumerator with the given minimum value.Returns the potential successor of a value for this enumerator in curried form.Returns the potential successor of a value for this enumerator.Returns a stream of the values from this enumerator, starting at the given value, counting up.Returns a stream of the values from this enumerator, starting at the min of given Bounded, ending at the max, counting up.<B> Enumerator<B> Invariant functor map over this enumerator.
-
Field Details
-
successor
-
predecessor
-
max
-
min
-
order
-
plus
-
booleanEnumerator
An enumerator forboolean. -
byteEnumerator
An enumerator forbyte. -
charEnumerator
An enumerator forchar. -
doubleEnumerator
An enumerator fordouble. -
floatEnumerator
An enumerator forfloat. -
intEnumerator
An enumerator forint. -
bigintEnumerator
An enumerator forBigInteger. -
bigdecimalEnumerator
An enumerator forBigDecimal. -
longEnumerator
An enumerator forlong. -
shortEnumerator
An enumerator forshort. -
orderingEnumerator
An enumerator forOrdering. -
naturalEnumerator
An enumerator forNatural
-
-
Constructor Details
-
Enumerator
-
-
Method Details
-
successor
-
successor
-
predecessor
-
predecessor
-
max
-
min
-
plus
-
plus
-
plus
-
plus
-
order
-
xmap
Invariant functor map over this enumerator.- Parameters:
f- The covariant map.g- The contra-variant map.- Returns:
- An enumerator after the given functions are applied.
-
toStream
-
toStream
Returns a stream of the values from this enumerator, starting at the min of given Bounded, ending at the max, counting up.- Parameters:
bounded- A value at which to begin the stream.- Returns:
- a stream of the values from this enumerator, cut by bounded, counting up.
-
setMin
Create a new enumerator with the given minimum value.- Parameters:
min- A minimum value.- Returns:
- A new enumerator identical to this one, but with the given minimum value.
-
setMax
Create a new enumerator with the given maximum value.- Parameters:
max- A maximum value.- Returns:
- A new enumerator identical to this one, but with the given maximum value.
-
enumerator
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<Long, Option<A>>> plus) Construct an enumerator. `- Parameters:
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.- Returns:
- An enumerator with the given values.
-
enumerator
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) Construct an enumerator. Theplusfunction is derived from thesuccessorandpredecessor.- Parameters:
successor- The successor function.predecessor- The predecessor function.max- The potential maximum value.min- The potential minimum value.order- The ordering for the type.- Returns:
- An enumerator with the given values.
-