Modifier and Type | Method and Description |
---|---|
Array<A> |
append(Array<A> aas)
Appends the given array to this array.
|
<B> Array<B> |
apply(Array<F<A,B>> lf)
Performs function application within an array (applicative functor pattern).
|
<B> Array<B> |
bind(F<A,Array<B>> f)
Binds the given function across each element of this array with a final join.
|
Array<A> |
filter(F<A,java.lang.Boolean> f)
Filters elements from this array by returning only elements which produce
true
when the given function is applied to them. |
<B> B |
foldLeft(F<B,F<A,B>> f,
B b)
Performs a left-fold reduction across this array.
|
<B> B |
foldRight(F<A,F<B,B>> f,
B b)
Performs a right-fold reduction across this array.
|
Unit |
foreach(F<A,Unit> f)
Performs a side-effect for each element of this array.
|
A |
get(int index)
Returns the element at the given index if it exists, fails otherwise.
|
boolean |
isEmpty()
Returns
true is this array is empty, false otherwise. |
boolean |
isNotEmpty()
Returns
false is this array is empty, true otherwise. |
java.util.Iterator<A> |
iterator()
Returns an iterator for this array.
|
int |
length()
Returns the length of this array.
|
<B> Array<B> |
map(F<A,B> f)
Maps the given function across this array.
|
Array<A> |
reverse()
Reverse this array in constant stack space.
|
<B> Array<B> |
sequence(Array<B> bs)
Performs a bind across each array element, but ignores the element value each time.
|
java.util.Collection<A> |
toCollection()
Projects an immutable collection of this array.
|
<X> Either<X,A> |
toEither(P1<X> x)
Returns an either projection of this array; the given argument in
Left if empty,
or the first element in Right . |
List<A> |
toList()
Returns a list projection of this array.
|
Option<A> |
toOption()
Returns an option projection of this array;
None if empty, or the first element
in Some . |
Stream<A> |
toStream()
Returns a stream projection of this array.
|
public java.util.Iterator<A> iterator()
for
-each loop.iterator
in interface java.lang.Iterable<A>
public A get(int index)
index
- The index at which to get the element to return.public int length()
public boolean isEmpty()
true
is this array is empty, false
otherwise.true
is this array is empty, false
otherwise.public boolean isNotEmpty()
false
is this array is empty, true
otherwise.false
is this array is empty, true
otherwise.public Option<A> toOption()
None
if empty, or the first element
in Some
.public <X> Either<X,A> toEither(P1<X> x)
Left
if empty,
or the first element in Right
.x
- The value to return in left if this array is empty.public List<A> toList()
public Stream<A> toStream()
public <B> Array<B> map(F<A,B> f)
f
- The function to map across this array.public Array<A> filter(F<A,java.lang.Boolean> f)
true
when the given function is applied to them.f
- The predicate function to filter on.public Unit foreach(F<A,Unit> f)
f
- The side-effect to perform for the given element.public <B> B foldRight(F<A,F<B,B>> f, B b)
f
- The function to apply on each element of the array.b
- The beginning value to start the application from.public <B> B foldLeft(F<B,F<A,B>> f, B b)
f
- The function to apply on each element of the array.b
- The beginning value to start the application from.public <B> Array<B> bind(F<A,Array<B>> f)
f
- The function to apply to each element of this array.public <B> Array<B> sequence(Array<B> bs)
bs
- The array to apply in the final join.public <B> Array<B> apply(Array<F<A,B>> lf)
lf
- The array of functions to apply.public Array<A> reverse()
public Array<A> append(Array<A> aas)
aas
- The array to append to this one.public java.util.Collection<A> toCollection()