E - the type of the elementsN - the type of what kind of RubyContract.Enumerator should be usedZ - the type to define if some methods are lazy or eager loadingstatic interface RubyContract.Enumerable<E,N extends RubyContract.Enumerator<?,?,?>,Z extends RubyContract.Enumerable<?,?,?>>
extends java.lang.Iterable<E>
RubyContract.Enumerable defines all methods of a Ruby Enumerable should have.| Modifier and Type | Method and Description |
|---|---|
boolean |
allʔ()
Checks if null is excluded.
|
boolean |
allʔ(BooleanBlock<? super E> block)
Checks if any result returned by the block is false.
|
boolean |
anyʔ()
Checks if any non-null object is included.
|
boolean |
anyʔ(BooleanBlock<? super E> block)
Checks if any result returned by the block is true.
|
<S> N |
chunk(java.lang.String methodName,
java.lang.Object... args)
Chunks elements into entries.
|
<S> N |
chunk(TransformBlock<? super E,? extends S> block)
Chunks elements into entries.
|
N |
collect()
Returns an enumerator of elements.
|
<S> Z |
collect(java.lang.String methodName,
java.lang.Object... args)
Transforms each element by given method.
|
<S> Z |
collect(TransformBlock<? super E,? extends S> block)
Transforms each element by the block.
|
N |
collectConcat()
Returns an enumerator of elements.
|
<S> Z |
collectConcat(TransformBlock<? super E,? extends java.util.List<? extends S>> block)
Turns each element into a List and then flattens it.
|
int |
count()
Counts the elements.
|
int |
count(BooleanBlock<? super E> block)
Counts the elements which are true returned by the block.
|
N |
cycle()
Generates a sequence from first element to last element and so on
infinitely.
|
void |
cycle(Block<? super E> block)
Generates a sequence from start element to end element and so on
infinitely.
|
N |
cycle(int n)
Generates a sequence from first element to last element, repeat n times.
|
void |
cycle(int n,
Block<? super E> block)
Generates a sequence from start element to end element, repeat n times.
|
N |
detect()
Returns an enumerator of elements.
|
E |
detect(BooleanBlock<? super E> block)
Finds the first element which gets true returned by the block.
|
Z |
drop(int n)
Drops the first n elements.
|
N |
dropWhile()
Returns an enumerator which contains only the first element.
|
Z |
dropWhile(BooleanBlock<? super E> block)
Drops the first n elements until an element gets false returned by the
block.
|
N |
each()
Returns an enumerator of elements.
|
RubyContract.Enumerable<E,N,Z> |
each(Block<? super E> block)
Yields each element to the block.
|
N |
eachCons(int n)
Iterates each element and puts the element with n - 1 consecutive
elements into a
RubyArray. |
void |
eachCons(int n,
Block<? super RubyArray<E>> block)
Iterates each element and yields the element with n - 1 consecutive
elements to the block.
|
N |
eachEntry()
Returns an enumerator of elements.
|
RubyContract.Enumerable<E,N,Z> |
eachEntry(Block<? super E> block)
Yields each element to the block.
|
N |
eachSlice(int n)
Slices elements into
RubyArrays with length n. |
void |
eachSlice(int n,
Block<? super RubyArray<E>> block)
Slices elements into
RubyArrays with length n and yield them to
the block. |
N |
eachWithIndex()
Iterates elements with their indices by Entry.
|
RubyContract.Enumerable<E,N,Z> |
eachWithIndex(WithIndexBlock<? super E> block)
Iterates elements with their indices and yields them to the block.
|
<O> N |
eachWithObject(O obj)
Iterates elements with an object O.
|
<O> O |
eachWithObject(O obj,
WithObjectBlock<? super E,? super O> block)
Iterates elements with an object O and yield them to the block.
|
RubyArray<E> |
entries()
Puts each element into a
RubyArray. |
N |
find()
Equivalent to
detect(). |
E |
find(BooleanBlock<? super E> block)
Equivalent to
detect(BooleanBlock). |
N |
findAll()
Returns an enumerator of elements.
|
Z |
findAll(BooleanBlock<? super E> block)
Finds all elements which are true returned by the block.
|
N |
findIndex()
Returns an enumerator of elements.
|
java.lang.Integer |
findIndex(BooleanBlock<? super E> block)
Returns the index of first element which gets true returned by the block.
|
java.lang.Integer |
findIndex(E target)
Returns the index of the target element.
|
E |
first()
Returns first element.
|
RubyArray<E> |
first(int n)
Returns the first n elements.
|
N |
flatMap()
Equivalent to
collectConcat(). |
<S> Z |
flatMap(TransformBlock<? super E,? extends java.util.List<? extends S>> block)
Equivalent to
collectConcat(TransformBlock). |
Z |
grep(java.lang.String regex)
Finds all elements which are matched by the regular expression.
|
<S> Z |
grep(java.lang.String regex,
java.lang.String methodName,
java.lang.Object... args)
Finds all elements which are matched by the regular expression and
invokes them by given method name.
|
<S> Z |
grep(java.lang.String regex,
TransformBlock<? super E,? extends S> block)
Finds all elements which are matched by the regular expression and
transforms them.
|
N |
groupBy()
Returns an enumerator of elements.
|
<S> RubyHash<S,RubyArray<E>> |
groupBy(java.lang.String methodName,
java.lang.Object... args)
Puts elements with the same result S invoked by given method name into a
Entry<S, RubyArray<E>>y of a
RubyHash. |
<S> RubyHash<S,RubyArray<E>> |
groupBy(TransformBlock<? super E,? extends S> block)
Puts elements with the same result S returned by the block into a
Entry<S, RubyArray<E>>y of a
RubyHash. |
boolean |
includeʔ(E target)
Checks if target element is included.
|
<I> I |
inject(I init,
java.lang.String methodName)
Reduces each element with initial value by a method of S, then assigns
the result back to initial value and so on.
|
<I> I |
inject(I init,
WithInitBlock<? super E,I> block)
Reduces each element with block, then assigns the result back to initial
value and so on.
|
E |
inject(ReduceBlock<E> block)
Assigns the first element as the initial value.
|
E |
inject(java.lang.String methodName)
Assigns the first element as the initial value.
|
RubyLazyEnumerator<E> |
lazy()
Returns a
RubyLazyEnumerator. |
N |
map()
Returns an enumerator of elements.
|
<S> Z |
map(java.lang.String methodName,
java.lang.Object... args)
Equivalent to
collect(String, Object...). |
<S> Z |
map(TransformBlock<? super E,? extends S> block)
Equivalent to
collect(TransformBlock). |
E |
max()
Finds the max element.
|
E |
max(java.util.Comparator<? super E> comp)
Finds the max element compared by the Comparator.
|
N |
maxBy()
Returns an enumerator of elements.
|
<S> E |
maxBy(java.util.Comparator<? super S> comp,
TransformBlock<? super E,? extends S> block)
Finds the max element for outputs transformed by the block and compared
by the Comparator.
|
<S> E |
maxBy(java.lang.String methodName,
java.lang.Object... args)
Finds the max element for outputs invoked by given method name.
|
<S> E |
maxBy(TransformBlock<? super E,? extends S> block)
Finds the max element for outputs transformed by the block.
|
boolean |
memberʔ(E target)
Equivalent to
includeʔ(Object). |
E |
min()
Finds the min element.
|
E |
min(java.util.Comparator<? super E> comp)
Finds the min element for outputs compared by the Comparator.
|
N |
minBy()
Returns an enumerator of elements.
|
<S> E |
minBy(java.util.Comparator<? super S> comp,
TransformBlock<? super E,? extends S> block)
Finds the min element for outputs transformed by the block and compared
by the Comparator.
|
<S> E |
minBy(java.lang.String methodName,
java.lang.Object... args)
Finds min element for outputs invoked by given method name.
|
<S> E |
minBy(TransformBlock<? super E,? extends S> block)
Finds the min element for outputs transformed by the block.
|
RubyArray<E> |
minmax()
Finds the min and max elements.
|
RubyArray<E> |
minmax(java.util.Comparator<? super E> comp)
Finds the min and max elements for outputs compared by the Comparator.
|
N |
minmaxBy()
Returns an enumerator of elements.
|
<S> RubyArray<E> |
minmaxBy(java.util.Comparator<? super S> comp,
TransformBlock<? super E,? extends S> block)
Finds the min and max elements for outputs transformed by the block and
compared by the Comparator.
|
<S> RubyArray<E> |
minmaxBy(java.lang.String methodName,
java.lang.Object... args)
Finds the min and max elements for outputs invoked by given method name.
|
<S> RubyArray<E> |
minmaxBy(TransformBlock<? super E,? extends S> block)
Finds the min and max elements for outputs transformed by the block.
|
boolean |
noneʔ()
Checks if elements contain only null objects.
|
boolean |
noneʔ(BooleanBlock<? super E> block)
Checks if elements contain only elements which are false returned by the
block.
|
boolean |
oneʔ()
Checks if elements contain only one element beside null.
|
boolean |
oneʔ(BooleanBlock<? super E> block)
Checks if elements contain only one element which are true returned by
the block.
|
N |
partition()
Returns an enumerator of elements.
|
RubyArray<RubyArray<E>> |
partition(BooleanBlock<? super E> block)
Divides elements into 2 groups by the given block.
|
<I> I |
reduce(I init,
java.lang.String methodName)
Equivalent to
inject(Object, String). |
<I> I |
reduce(I init,
WithInitBlock<? super E,I> block)
Equivalent to
inject(Object, WithInitBlock). |
E |
reduce(ReduceBlock<E> block)
Equivalent to
inject(ReduceBlock). |
E |
reduce(java.lang.String methodName)
Equivalent to
inject(String). |
N |
reject()
Returns an enumerator of elements.
|
Z |
reject(BooleanBlock<? super E> block)
Filters all elements which are true returned by the block.
|
N |
reverseEach()
Returns a reversed enumerator of elements.
|
RubyContract.Enumerable<E,N,Z> |
reverseEach(Block<? super E> block)
Iterates each element reversely by given block.
|
N |
select()
Returns an enumerator of elements.
|
Z |
select(BooleanBlock<? super E> block)
Equivalent to
findAll(BooleanBlock) |
N |
sliceBefore(BooleanBlock<? super E> block)
|
N |
sliceBefore(java.lang.String regex)
|
RubyArray<E> |
sort()
Sorts elements and puts them into a
RubyArray. |
N |
sortBy()
Returns an enumerator of elements.
|
<S> RubyArray<E> |
sortBy(java.util.Comparator<? super E> comp1,
java.util.Comparator<? super S> comp2,
TransformBlock<? super E,? extends S> block)
Sorts elements by the ordering of outputs transformed by the block
induced by the Comparator for S and applies the Comparator for E again
before puts them into a
RubyArray. |
<S> RubyArray<E> |
sortBy(java.util.Comparator<? super S> comp,
TransformBlock<? super E,? extends S> block)
Sorts elements by the ordering of outputs transformed by the block
induced by the Comparator, then puts them into a
RubyArray. |
<S> RubyArray<E> |
sortBy(java.lang.String methodName,
java.lang.Object... args)
Sorts elements by the ordering of the outputs invoked by given method
name, then puts them into a
RubyArray. |
<S> RubyArray<E> |
sortBy(TransformBlock<? super E,? extends S> block)
Sorts elements by the ordering of outputs transformed by the block, then
puts them into a
RubyArray. |
Z |
take(int n)
Takes the first n elements.
|
N |
takeWhile()
Returns an enumerator which contains only the first element.
|
Z |
takeWhile(BooleanBlock<? super E> block)
Takes elements until an element gets false returned by the block.
|
RubyArray<E> |
toA()
Puts all elements into a
RubyArray. |
Z |
zip(java.lang.Iterable<? extends E>... others)
Groups elements which get the same indices among all other Iterables into
RubyArrays. |
Z |
zip(java.util.List<? extends java.lang.Iterable<? extends E>> others)
Groups elements which get the same indices among all other Lists into
RubyArrays. |
void |
zip(java.util.List<? extends java.lang.Iterable<? extends E>> others,
Block<? super RubyArray<E>> block)
Groups elements which get the same indices among all other Iterables into
RubyArrays and yields them to the block. |
boolean allʔ()
boolean allʔ(BooleanBlock<? super E> block)
block - to check elementsboolean anyʔ()
boolean anyʔ(BooleanBlock<? super E> block)
block - to check elements<S> N chunk(TransformBlock<? super E,? extends S> block)
RubyArray which contains
elements having the same result returned by the block and aside to each
other.S - the type of transformed elementsblock - to chunk elementsRubyContract.Enumerator<S> N chunk(java.lang.String methodName, java.lang.Object... args)
RubyArray which
contains elements having the same result returned by the block and aside
to each other.S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a MethodRubyContract.EnumeratorN collect()
RubyContract.Enumerator<S> Z collect(TransformBlock<? super E,? extends S> block)
S - the type of transformed elementsblock - to transform elementsRubyContract.Enumerable<S> Z collect(java.lang.String methodName, java.lang.Object... args)
S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a MethodRubyContract.EnumerableN collectConcat()
RubyContract.Enumerator<S> Z collectConcat(TransformBlock<? super E,? extends java.util.List<? extends S>> block)
S - the type of transformed elementsblock - to take element into a ListRubyContract.Enumerableint count()
int count(BooleanBlock<? super E> block)
block - to define elements to be countedN cycle()
RubyContract.EnumeratorN cycle(int n)
n - times to repeatRubyContract.Enumeratorvoid cycle(int n,
Block<? super E> block)
n - times to repeatblock - to yield each elementvoid cycle(Block<? super E> block)
block - to yield each elementN detect()
RubyContract.EnumeratorE detect(BooleanBlock<? super E> block)
block - to filter elementsZ drop(int n)
n - number of elements to dropRubyContract.EnumerableN dropWhile()
RubyContract.EnumeratorZ dropWhile(BooleanBlock<? super E> block)
block - to define which elements to be droppedRubyContract.EnumerableN each()
RubyContract.EnumeratorRubyContract.Enumerable<E,N,Z> each(Block<? super E> block)
block - to yield each elementRubyContract.EnumerableN eachCons(int n)
RubyArray.n - number of consecutive elementsRubyContract.Enumeratorvoid eachCons(int n,
Block<? super RubyArray<E>> block)
n - number of consecutive elementsblock - to yield the List of consecutive elementsN eachEntry()
RubyContract.EnumeratorRubyContract.Enumerable<E,N,Z> eachEntry(Block<? super E> block)
block - to yield each elementRubyContract.EnumerableN eachSlice(int n)
RubyArrays with length n.n - size of each sliceRubyContract.Enumeratorvoid eachSlice(int n,
Block<? super RubyArray<E>> block)
RubyArrays with length n and yield them to
the block.n - size of each sliceblock - to yield each sliceN eachWithIndex()
RubyContract.EnumeratorRubyContract.Enumerable<E,N,Z> eachWithIndex(WithIndexBlock<? super E> block)
block - to yield each elementRubyContract.Enumerable<O> N eachWithObject(O obj)
O - the type of transformed elementsobj - an object ORubyContract.Enumerator<O> O eachWithObject(O obj,
WithObjectBlock<? super E,? super O> block)
O - the type of transformed elementsobj - an object Oblock - to yield each EntryN find()
detect().RubyContract.EnumeratorE find(BooleanBlock<? super E> block)
detect(BooleanBlock).block - to filter elementsN findAll()
RubyContract.EnumeratorZ findAll(BooleanBlock<? super E> block)
block - to filter elementsRubyContract.EnumerableN findIndex()
RubyContract.Enumeratorjava.lang.Integer findIndex(BooleanBlock<? super E> block)
block - to check elementsjava.lang.Integer findIndex(E target)
target - to be foundE first()
RubyArray<E> first(int n)
n - number of elementsRubyArrayjava.lang.IllegalArgumentException - if n is less than 0N flatMap()
collectConcat().RubyContract.Enumerator<S> Z flatMap(TransformBlock<? super E,? extends java.util.List<? extends S>> block)
collectConcat(TransformBlock).S - the type of transformed elementsblock - to take element into a ListRubyContract.EnumerableZ grep(java.lang.String regex)
regex - regular expressionRubyContract.Enumerable<S> Z grep(java.lang.String regex, TransformBlock<? super E,? extends S> block)
S - the type of transformed elementsregex - regular expressionblock - to transform elementsRubyContract.Enumerable<S> Z grep(java.lang.String regex, java.lang.String methodName, java.lang.Object... args)
S - the type of transformed elementsregex - regular expressionmethodName - name of a Methodargs - arguments of a MethodRubyContract.EnumerableN groupBy()
RubyContract.Enumerator<S> RubyHash<S,RubyArray<E>> groupBy(TransformBlock<? super E,? extends S> block)
RubyHash.S - the type of transformed elementsblock - to group each elementRubyHash<S> RubyHash<S,RubyArray<E>> groupBy(java.lang.String methodName, java.lang.Object... args)
RubyHash.S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a MethodRubyHashboolean includeʔ(E target)
target - to be searchedE inject(ReduceBlock<E> block)
block - to reduce each element<I> I inject(I init,
WithInitBlock<? super E,I> block)
I - the type of transformed elementsinit - initial valueblock - to reduce each element<I> I inject(I init,
java.lang.String methodName)
I - the type of transformed elementsinit - initial valuemethodName - method used to reduce elementsjava.lang.IllegalArgumentException - if method not foundjava.lang.RuntimeException - if invocation failedE inject(java.lang.String methodName)
methodName - method used to reduce elementsjava.lang.IllegalArgumentException - if method not foundjava.lang.RuntimeException - if invocation failedRubyLazyEnumerator<E> lazy()
RubyLazyEnumerator.RubyLazyEnumeratorN map()
RubyContract.Enumerator<S> Z map(TransformBlock<? super E,? extends S> block)
collect(TransformBlock).S - the type of transformed elementsblock - to transform elementsRubyContract.Enumerable<S> Z map(java.lang.String methodName, java.lang.Object... args)
collect(String, Object...).S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a MethodRubyContract.EnumerableE max()
E max(java.util.Comparator<? super E> comp)
comp - a ComparatorN maxBy()
RubyContract.Enumerator<S> E maxBy(java.util.Comparator<? super S> comp, TransformBlock<? super E,? extends S> block)
S - the type of transformed elementscomp - a Comparatorblock - to transform elements<S> E maxBy(TransformBlock<? super E,? extends S> block)
S - the type of transformed elementsblock - to transform elements<S> E maxBy(java.lang.String methodName, java.lang.Object... args)
S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a Methodboolean memberʔ(E target)
includeʔ(Object).target - to be foundE min()
E min(java.util.Comparator<? super E> comp)
comp - a ComparatorN minBy()
RubyContract.Enumerator<S> E minBy(java.util.Comparator<? super S> comp, TransformBlock<? super E,? extends S> block)
S - the type of transformed elementscomp - a Comparatorblock - to transform elements<S> E minBy(TransformBlock<? super E,? extends S> block)
S - the type of transformed elementsblock - to transform elements<S> E minBy(java.lang.String methodName, java.lang.Object... args)
S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a MethodRubyArray<E> minmax(java.util.Comparator<? super E> comp)
comp - a ComparatorRubyArrayN minmaxBy()
RubyContract.Enumerator<S> RubyArray<E> minmaxBy(java.util.Comparator<? super S> comp, TransformBlock<? super E,? extends S> block)
S - the type of transformed elementscomp - a Comparatorblock - to transform elementsRubyArray<S> RubyArray<E> minmaxBy(TransformBlock<? super E,? extends S> block)
S - the type of transformed elementsblock - to transform elementsRubyArray<S> RubyArray<E> minmaxBy(java.lang.String methodName, java.lang.Object... args)
S - the type of transformed elementsmethodName - name of a Methodargs - arguments of a MethodRubyArrayboolean noneʔ()
boolean noneʔ(BooleanBlock<? super E> block)
block - to check elementsboolean oneʔ()
boolean oneʔ(BooleanBlock<? super E> block)
block - to check elementsN partition()
RubyContract.EnumeratorRubyArray<RubyArray<E>> partition(BooleanBlock<? super E> block)
E reduce(ReduceBlock<E> block)
inject(ReduceBlock).block - to reduce each element<I> I reduce(I init,
WithInitBlock<? super E,I> block)
inject(Object, WithInitBlock).I - the type of transformed elementsinit - initial valueblock - to reduce each element<I> I reduce(I init,
java.lang.String methodName)
inject(Object, String).I - the type of transformed elementsinit - initial valuemethodName - method used to reduce elementsjava.lang.IllegalArgumentException - if method not foundjava.lang.RuntimeException - if invocation failedE reduce(java.lang.String methodName)
inject(String).methodName - method used to reduce elementsjava.lang.IllegalArgumentException - if method not foundjava.lang.RuntimeException - if invocation failedN reject()
RubyContract.EnumeratorZ reject(BooleanBlock<? super E> block)
block - to filter elementsRubyContract.EnumerableN reverseEach()
RubyContract.EnumeratorRubyContract.Enumerable<E,N,Z> reverseEach(Block<? super E> block)
block - to yield each elementRubyContract.EnumerableN select()
RubyContract.EnumeratorZ select(BooleanBlock<? super E> block)
findAll(BooleanBlock)block - to filter elementsRubyContract.EnumerableN sliceBefore(BooleanBlock<? super E> block)
RubyArrays and the first element of each
RubyArray should get true returned by the block.block - to check where to do sliceRubyContract.EnumeratorN sliceBefore(java.lang.String regex)
RubyArrays and the first element of each
RubyArray should be matched by the regex.regex - to check where to do sliceRubyContract.EnumeratorRubyArray<E> sort()
RubyArray.RubyArrayjava.lang.IllegalArgumentException - when any 2 elements are not comparableN sortBy()
RubyContract.Enumerator<S> RubyArray<E> sortBy(java.util.Comparator<? super S> comp, TransformBlock<? super E,? extends S> block)
RubyArray.S - the type of transformed elementscomp - a Comparatorblock - to transform elementsRubyArray<S> RubyArray<E> sortBy(java.util.Comparator<? super E> comp1, java.util.Comparator<? super S> comp2, TransformBlock<? super E,? extends S> block)
RubyArray.S - the type of transformed elementscomp1 - a Comparator for Ecomp2 - a Comparator for Sblock - to transform elementsRubyArray<S> RubyArray<E> sortBy(TransformBlock<? super E,? extends S> block)
RubyArray.S - the type of transformed elementsblock - to transform elementsRubyArray<S> RubyArray<E> sortBy(java.lang.String methodName, java.lang.Object... args)
RubyArray.methodName - name of a Methodargs - arguments of a MethodRubyArrayZ take(int n)
n - number of elementsRubyContract.EnumerableN takeWhile()
RubyContract.EnumeratorZ takeWhile(BooleanBlock<? super E> block)
block - to filter elementsRubyContract.EnumerableZ zip(java.lang.Iterable<? extends E>... others)
RubyArrays.others - an array of IterableRubyContract.EnumerableZ zip(java.util.List<? extends java.lang.Iterable<? extends E>> others)
RubyArrays.others - a List of IterableRubyContract.Enumerablevoid zip(java.util.List<? extends java.lang.Iterable<? extends E>> others, Block<? super RubyArray<E>> block)
RubyArrays and yields them to the block.others - a List of Iterablesblock - to yield zipped elements