Modifier and Type | Method and Description |
---|---|
Stream<Collection<T>> |
collate(int size)
Groups a the elements of a
Stream into groups of length size . |
Stream<Collection<T>> |
collate(int size,
boolean keepRemainder)
Groups a the elements of a
Stream into groups of length size . |
Stream<Collection<T>> |
collate(int size,
int step)
Groups a the elements of a
Stream into groups of length size
using a step-size of step . |
Stream<Collection<T>> |
collate(int size,
int step,
boolean keepRemainder)
Groups a the elements of a
Stream into groups of length size
using a step-size of step . |
Stream<T> |
concat(Iterator<? extends T> other)
Returns a new
Stream which will iterate the elements in the current Stream ,
followed by the elements in the other Stream . |
Stream<T> |
filter(Closure<Boolean> predicate)
Filter the current stream, passing each element through a predicate filter.
|
Stream<T> |
filter(Predicate<T> predicate)
Filter the current stream, passing each element through a predicate filter (Java friendly version).
|
Stream<T> |
filterWithIndex(Closure<Boolean> predicate)
Filter the current stream, passing each element and it's index through a predicate filter.
|
Stream<T> |
filterWithIndex(IndexedPredicate<T> predicate)
Filter the current stream, passing each element and its index through a predicate filter (Java friendly version).
|
<U> Stream<U> |
flatMap(Closure<? extends Collection<U>> map)
Takes a
Closure that returns a Collection . |
<U> Stream<U> |
flatMap(Function<T,? extends Collection<U>> map)
Takes a
Function that returns a Collection . |
<U> Stream<U> |
flatMapWithIndex(Closure<? extends Collection<U>> map)
Takes a
Closure that returns a Collection . |
<U> Stream<U> |
flatMapWithIndex(IndexedFunction<T,? extends Collection<U>> map)
Takes an
IndexedFunction that returns a Collection . |
static Stream<Boolean> |
from(boolean[] array)
Construct a
Stream that iterates every Boolean in an array. |
static Stream<String> |
from(BufferedReader reader)
Construct a
Stream from a BufferedReader that iterates the lines in it. |
static Stream<Byte> |
from(byte[] array)
Construct a
Stream that iterates every byte in an array. |
static Stream<Character> |
from(char[] array)
Construct a
Stream that iterates every Character in an array. |
static <T> Stream<T> |
from(Closure<T> closure)
Construct a
Stream that for every element, returns the result of calling the Closure . |
static Stream<Double> |
from(double[] array)
Construct a
Stream that iterates every Double in an array. |
static Stream<Float> |
from(float[] array)
Construct a
Stream that iterates every Float in an array. |
static Stream<Integer> |
from(int[] array)
Construct a
Stream that iterates every Integer in an array. |
static <T> Stream<T> |
from(Iterable<T> iterable)
Construct a
Stream from an Iterable . |
static <T> Stream<T> |
from(Iterator<T> iterator)
Construct a
Stream from an Iterator . |
static Stream<JarEntry> |
from(JarFile file)
|
static Stream<Long> |
from(long[] array)
Construct a
Stream that iterates every Long in an array. |
static <K,V> Stream<Map<K,V>> |
from(Map<K,? extends Iterable<V>> map)
Construct a
Stream from a Map of Iterables. |
static Stream<Short> |
from(short[] array)
Construct a
Stream that iterates every Short in an array. |
static <T> Stream<T> |
from(Stream<T> stream)
Construct a
Stream from another Stream . |
static <T> Stream<T> |
from(T object)
Construct a
Stream that for every element, returns object . |
static <T> Stream<T> |
from(T[] array)
Construct a
Stream that iterates every Object in an array. |
static Stream<ZipEntry> |
from(ZipFile file)
|
boolean |
hasNext() |
<U> Stream<U> |
map(Closure<U> map)
Maps the elements of a
Stream to a new value as they are requested. |
<U> Stream<U> |
map(Function<T,U> map)
Maps the elements of a
Stream to a new value as they are requested. |
<U> Stream<U> |
mapWithIndex(Closure<U> map)
Maps the elements of a
Stream to a new value as they are requested. |
<U> Stream<U> |
mapWithIndex(IndexedFunction<T,U> map)
Maps the elements of a
Stream to a new value as they are requested. |
T |
next() |
void |
remove() |
Stream<T> |
repeat()
When this stream completes, repeat it's output endlessly.
|
Stream<T> |
repeat(int count)
This stream will repeat
count times. |
Stream<T> |
skip(int n)
Skip
n elements. |
Stream<T> |
take(int n)
Limits the
Stream to n elements. |
Stream<T> |
tap(Closure<Void> output)
Inspect every value in the
Stream and pass it on unmodified. |
Stream<T> |
tap(Function<T,Void> output)
Inspect every value in the
Stream and pass it on. |
Stream<T> |
tapEvery(int n,
Closure<Void> output)
Inspect the every nth value in the
Stream and pass it on unmodified. |
Stream<T> |
tapEvery(int n,
Function<T,Void> output)
Inspect the every nth value in the
Stream and pass it on. |
Stream<T> |
tapEveryWithIndex(int n,
Closure<Void> output)
Inspect the every nth value in the
Stream with its index and pass it on unmodified. |
Stream<T> |
tapEveryWithIndex(int n,
IndexedFunction<T,Void> output)
Inspect the every nth value in the
Stream with its index and pass it on unmodified. |
Stream<T> |
tapWithIndex(Closure<Void> output)
Inspect every value in the
Stream with its index and pass it on unmodified. |
Stream<T> |
tapWithIndex(IndexedFunction<T,Void> output)
Inspect every value in the
Stream with its index and pass it on unmodified. |
Stream<T> |
until(Closure<Boolean> predicate)
When the
Closure predicate returns true , the stream is stopped. |
Stream<T> |
until(Predicate<T> predicate)
When the
Predicate returns true , the stream is stopped. |
Stream<T> |
untilWithIndex(Closure<Boolean> predicate)
Calls the
Closure predicate with the current element and the index in the stream. |
Stream<T> |
untilWithIndex(IndexedPredicate<T> predicate)
Calls the
IndexedPredicate with the current element and the index in the stream. |
<U,V> Stream<V> |
zip(Iterable<U> other,
Closure<V> map) |
<U,V> Stream<V> |
zip(Iterable<U> other,
Function2<T,U,V> map) |
<U,V> Stream<V> |
zip(Iterator<U> other,
Closure<V> map)
Takes another
Iterator or Stream and calls the two arg Closure
to zip the two together. |
<U,V> Stream<V> |
zip(Iterator<U> other,
Function2<T,U,V> map)
Takes another
Iterator or Stream and calls the two arg Function2
to zip the two together. |
<U,V> Stream<V> |
zipWithIndex(Iterable<U> other,
Closure<V> map) |
<U,V> Stream<V> |
zipWithIndex(Iterable<U> other,
IndexedFunction2<T,U,V> map) |
<U,V> Stream<V> |
zipWithIndex(Iterator<U> other,
Closure<V> map)
Takes another
Iterator or Stream and calls the three arg Closure
to zip the two together along with the current index. |
<U,V> Stream<V> |
zipWithIndex(Iterator<U> other,
IndexedFunction2<T,U,V> map)
Takes another
Iterator or Stream and calls the three arg IndexedFunction2
to zip the two together along with the current index. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public Stream<T> filter(Closure<Boolean> predicate)
import groovy.stream.* assert Stream.from( 1..3 ) .filter { it % 2 == 1 } .collect() == [ 1, 3 ]
predicate
- A single parameter closure to pass the element through,
returning true
if the element is to be included.Stream
wrapping a FilteringIterator
public Stream<T> filter(Predicate<T> predicate)
predicate
- A Predicate
instance returning true
from it's call
method
if the element is to be included.Stream
wrapping a FilteringIteratorForPredicate
public Stream<T> filterWithIndex(Closure<Boolean> predicate)
import groovy.stream.* assert Stream.from( 1..3 ) .filterWithIndex { it, index -> index % 2 == 1 } .collect() == [ 2 ]
predicate
- A two parameter closure, the first parameter being the
element in the Stream
, the second the index (starting at 0).Stream
wrapping a FilteringIterator
public Stream<T> filterWithIndex(IndexedPredicate<T> predicate)
predicate
- An IndexedPredicate
instance returning true
from it's call
method
if the element is to be included.Stream
wrapping a FilteringIteratorForIndexedPredicate
public Stream<T> concat(Iterator<? extends T> other)
Stream
which will iterate the elements in the current Stream
,
followed by the elements in the other
Stream
.
import groovy.stream.* def a = Stream.from( 1..3 ) def b = Stream.from( 'a'..'c' ) assert a.concat( b ).collect() == [ 1, 2, 3, 'a', 'b', 'c' ]
other
- The Stream
to iterate after the current one is exhausted.Stream
wrapping a ConcatenationIterator
public Stream<T> skip(int n)
n
elements.
import groovy.stream.* assert Stream.from( 1..10 ) .skip( 6 ).collect() == [ 7, 8, 9, 10 ]
n
- the number of elements to skipStream
wrapping a SkipIterator
public <U> Stream<U> flatMap(Closure<? extends Collection<U>> map)
Closure
that returns a Collection
. Each element
in this Collection
is passed on in turn, before the next element is
fetched from upstream, and the Closure executed again.
import groovy.stream.* assert Stream.from( 1..3 ) .flatMap { [ it ] * it } .collect() == [ 1, 2, 2, 3, 3, 3 ]
U
- The type of the new Stream.map
- A single parameter closure to pass the element through,
returning a new Collection of elements to iterate.Stream
wrapping a FlatMapIterator
public <U> Stream<U> flatMap(Function<T,? extends Collection<U>> map)
Function
that returns a Collection
. Each element
in this Collection
is passed on in turn, before the next element is
fetched from upstream, and the Function
is executed again.U
- The type of the new Stream.map
- A single Function
to pass the element through, returning a
new Collection of elements to iterate.Stream
wrapping a FlatMapIteratorForFunction
public <U> Stream<U> flatMapWithIndex(Closure<? extends Collection<U>> map)
Closure
that returns a Collection
. Each element
in this Collection
is passed on in turn, before the next element is
fetched from upstream, and the Closure executed again.
import groovy.stream.* assert Stream.from( 1..3 ) .flatMapWithIndex { it, index -> [ it ] * index } .collect() == [ 2, 3, 3 ]
U
- The type of the new Stream.map
- A two parameter closure to pass the element and it's index through,
returning a new Collection of elements to iterate.Stream
wrapping a FlatMapIterator
public <U> Stream<U> flatMapWithIndex(IndexedFunction<T,? extends Collection<U>> map)
IndexedFunction
that returns a Collection
. Each element
in this Collection
is passed on in turn, before the next element is
fetched from upstream, and the IndexedFunction
is executed again.U
- The type of the new Stream.map
- A single IndexedFunction
to pass the element and its index through,
returning a new Collection of elements to iterate.Stream
wrapping a FlatMapIteratorForIndexedFunction
public Stream<T> tap(Closure<Void> output)
Stream
and pass it on unmodified.
import groovy.stream.* def list = [] assert Stream.from( 1..3 ) .tap { list << it } .collect() == [ 1, 2, 3 ] assert list == [ 1, 2, 3 ]
output
- The Closure
to be called for every elementStream
wrapping a TapIterator
public Stream<T> tap(Function<T,Void> output)
Stream
and pass it on.output
- The Function
to be called for every elementStream
wrapping a TapIteratorForFunction
tap(groovy.lang.Closure)
public Stream<T> tapEvery(int n, Closure<Void> output)
Stream
and pass it on unmodified.
import groovy.stream.* def list = [] assert Stream.from( 1..3 ) .tapEvery( 2 ) { list << it } .collect() == [ 1, 2, 3 ] assert list == [ 2 ]
n
- the elements to inspectoutput
- The Closure
to be called for every nth elementStream
wrapping a TapIterator
public Stream<T> tapEvery(int n, Function<T,Void> output)
Stream
and pass it on.n
- the elements to inspectoutput
- The Function
to be called for every nth elementStream
wrapping a TapIteratorForFunction
tapEvery(int, groovy.lang.Closure)
public Stream<T> tapWithIndex(Closure<Void> output)
Stream
with its index
and pass it on unmodified.
import groovy.stream.* def list = [] assert Stream.from( 1..3 ) .tapWithIndex { it, idx -> list << [ (it):idx ] } .collect() == [ 1, 2, 3 ] assert list == [ [ 1:0 ], [ 2:1 ], [ 3:2 ] ]
output
- The closure to call for each element in the Stream.Stream
wrapping a TapIterator
public Stream<T> tapWithIndex(IndexedFunction<T,Void> output)
Stream
with its index
and pass it on unmodified.output
- The IndexedFunction
to call for each element in the Stream.Stream
wrapping a TapIteratorForIndexedFunction
tapWithIndex(groovy.lang.Closure)
public Stream<T> tapEveryWithIndex(int n, Closure<Void> output)
Stream
with its index and pass it on unmodified.
import groovy.stream.* def list = [] assert Stream.from( 1..3 ) .tapEveryWithIndex( 2 ) { it, index -> list << [ (it):index ] } .collect() == [ 1, 2, 3 ] assert list == [ [2:1] ]
n
- the elements to inspectoutput
- The Closure
to be called for every nth elementStream
wrapping a TapIterator
public Stream<T> tapEveryWithIndex(int n, IndexedFunction<T,Void> output)
Stream
with its index and pass it on unmodified.n
- the elements to inspectoutput
- The IndexedFunction
to be called for every nth elementStream
wrapping a TapIteratorForIndexedFunction
tapEveryWithIndex(int, groovy.lang.Closure)
public <U> Stream<U> map(Closure<U> map)
Stream
to a new value as they are requested. Each
element is passed in to a one arg closure, and the result of the Closure
is returned as the next element in the Stream
. The element is also
set as the delegate of the Closure
, so you can access map entries
by name.
import groovy.stream.* assert Stream.from( x:1..3, y:'a'..'c' ) .map { "$x:$y" } .collect() == [ "1:a", "1:b", "1:c", "2:a", "2:b", "2:c", "3:a", "3:b", "3:c" ]
U
- The type of the new Stream.map
- The transforming Closure.Stream
wrapping a TransformingIterator
public <U> Stream<U> map(Function<T,U> map)
Stream
to a new value as they are requested. Each
element is passed in to a Function
, the result of which is returned as the
next element in the Stream
.U
- The type of the new Stream.map
- The transforming Function
.Stream
wrapping a TransformingIteratorForFunction
map(groovy.lang.Closure)
public <U> Stream<U> mapWithIndex(Closure<U> map)
Stream
to a new value as they are requested. Each
element plus an index is passed in to a two arg closure, and the result of
the Closure
is returned as the next element in the Stream
.
The element is also set as the delegate of the Closure
, so you can
access map entries by name.
import groovy.stream.* assert Stream.from( x:1..3, y:'a'..'c' ) .mapWithIndex { it, idx -> "${x}:${it.y}:${idx}" } .collect() == [ "1:a:0", "1:b:1", "1:c:2", "2:a:3", "2:b:4", "2:c:5", "3:a:6", "3:b:7", "3:c:8" ]
U
- The type of the new Stream.map
- The transforming Closure.Stream
wrapping a TransformingIterator
public <U> Stream<U> mapWithIndex(IndexedFunction<T,U> map)
Stream
to a new value as they are requested. Each
element plus an index is passed in to an IndexedFunction
, and the result of
this is returned as the next element in the Stream
.U
- The type of the new Stream.map
- The transforming IndexedFunction
.Stream
wrapping a TransformingIteratorForIndexedFunction
mapWithIndex(groovy.lang.Closure)
public Stream<T> until(Closure<Boolean> predicate)
Closure
predicate returns true
, the stream is stopped.
import groovy.stream.* assert Stream.from( 1..5 ) .until { it > 3 } .collect() == [ 1, 2, 3 ]
predicate
- The Closure
that stops the Stream when it returns true
.Stream
wrapping an UntilIterator
public Stream<T> until(Predicate<T> predicate)
Predicate
returns true
, the stream is stopped.predicate
- The Predicate
that stops the Stream when it returns true
.Stream
wrapping an UntilIteratorForPredicate
until(groovy.lang.Closure)
public Stream<T> untilWithIndex(Closure<Boolean> predicate)
Closure
predicate with the current element and the index in the stream.
When the predicate returns true
, the stream is stopped.
import groovy.stream.* assert Stream.from( 1..5 ) .untilWithIndex { it, index -> index == 2 } .collect() == [ 1, 2 ]
predicate
- The Closure
that stops the Stream when it returns true
.Stream
wrapping an UntilIterator
public Stream<T> untilWithIndex(IndexedPredicate<T> predicate)
IndexedPredicate
with the current element and the index in the stream.
When the predicate returns true
, the stream is stopped.predicate
- The IndexedPredicate
that stops the Stream when it returns true
.Stream
wrapping an UntilIteratorForIndexedPredicate
public Stream<Collection<T>> collate(int size)
Stream
into groups of length size
.
import groovy.stream.* assert Stream.from( 1..9 ) .collate( 4 ) .collect() == [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9 ] ]
size
- the size of each collated groupStream
wrapping an CollatingIterator
public Stream<Collection<T>> collate(int size, boolean keepRemainder)
Stream
into groups of length size
.
import groovy.stream.* assert Stream.from( 1..9 ) .collate( 4, false ) .collect() == [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ]
size
- the size of each collated groupkeepRemainder
- Should any remaining objects be returned at the endStream
wrapping an CollatingIterator
public Stream<Collection<T>> collate(int size, int step)
Stream
into groups of length size
using a step-size of step
.
import groovy.stream.* assert Stream.from( 1..9 ) .collate( 4, 1 ) .collect() == [ [ 1, 2, 3, 4 ], [ 2, 3, 4, 5 ], [ 3, 4, 5, 6 ], [ 4, 5, 6, 7 ], [ 5, 6, 7, 8 ], [ 6, 7, 8, 9 ], [ 7, 8, 9 ], [ 8, 9 ], [ 9 ] ]
size
- the size of each collated groupstep
- How many to increment the window by each turnStream
wrapping an CollatingIterator
public Stream<Collection<T>> collate(int size, int step, boolean keepRemainder)
Stream
into groups of length size
using a step-size of step
.
import groovy.stream.* assert Stream.from( 1..9 ) .collate( 4, 1, false ) .collect() == [ [ 1, 2, 3, 4 ], [ 2, 3, 4, 5 ], [ 3, 4, 5, 6 ], [ 4, 5, 6, 7 ], [ 5, 6, 7, 8 ], [ 6, 7, 8, 9 ] ]
size
- the size of each collated groupstep
- How many to increment the window by each turnkeepRemainder
- Should any remaining objects be returned at the endStream
wrapping an CollatingIterator
public <U,V> Stream<V> zip(Iterator<U> other, Closure<V> map)
Iterator
or Stream
and calls the two arg Closure
to zip the two together.
import groovy.stream.* def numbers = Stream.from 1..3 def letters = Stream.from 'a'..'d' assert numbers.zip( letters ) { n, l -> "$n:$l" } .collect() == [ "1:a", "2:b", "3:c" ]
U
- The type of the secondary Iterator
.V
- The type of the new Iterator
.other
- The other Iterator
map
- The 2 arg Closure
to call with each next element from the StreamStream
wrapping a ZipIterator
public <U,V> Stream<V> zip(Iterator<U> other, Function2<T,U,V> map)
Iterator
or Stream
and calls the two arg Function2
to zip the two together.U
- The type of the secondary Iterator
.V
- The type of the new Iterator
.other
- The other Iterator
map
- The 2 arg Function2
to call with each next element from the StreamStream
wrapping a ZipIteratorForFunction
zip(java.util.Iterator, groovy.lang.Closure)
public <U,V> Stream<V> zipWithIndex(Iterator<U> other, Closure<V> map)
Iterator
or Stream
and calls the three arg Closure
to zip the two together along with the current index.
import groovy.stream.* def numbers = Stream.from 1..3 def letters = Stream.from 'a'..'d' assert numbers.zipWithIndex( letters ) { n, l, i -> "$n:$l:$i" } .collect() == [ "1:a:0", "2:b:1", "3:c:2" ]
U
- The type of the secondary Iterator
.V
- The type of the new Iterator
.other
- The other Iterator
map
- The 3 arg Closure
to call with each next element from the Stream and the
current stream indexStream
wrapping a ZipIterator
public <U,V> Stream<V> zipWithIndex(Iterator<U> other, IndexedFunction2<T,U,V> map)
Iterator
or Stream
and calls the three arg IndexedFunction2
to zip the two together along with the current index.U
- The type of the secondary Iterator
.V
- The type of the new Iterator
.other
- The other Iterator
map
- The 3 arg IndexedFunction2
to call with each next element from the Stream and the
current stream indexStream
wrapping a ZipIteratorForIndexedFunction
zipWithIndex(java.util.Iterator, groovy.lang.Closure)
public <U,V> Stream<V> zipWithIndex(Iterable<U> other, IndexedFunction2<T,U,V> map)
public Stream<T> repeat()
import groovy.stream.* def numbers = Stream.from 1..3 // We will just take the first 12 elements of this infinite stream assert numbers.repeat().take(12).collect() == [1,2,3,1,2,3,1,2,3,1,2,3]
Stream
wrapping a RepeatingIterator
public Stream<T> repeat(int count)
count
times.
If count is 0
, the Stream will be empty. If 1
, no repetition will be performed.
import groovy.stream.* def numbers = Stream.from(['alice', 'bob']) assert numbers.repeat(2).collect() == ['alice','bob','alice','bob']
count
- The number of times to repeat the element in this Stream once it is exhausted.Stream
wrapping a RepeatingIterator
public Stream<T> take(int n)
Stream
to n
elements.
import groovy.stream.* assert Stream.from( 1..9 ) .take( 3 ) .collect() == [ 1, 2, 3 ]
n
- The number of element to limit the Stream
to.Stream
wrapping a LimitedIterator
public static <K,V> Stream<Map<K,V>> from(Map<K,? extends Iterable<V>> map)
Stream
from a Map
of Iterables.
import groovy.stream.* assert Stream.from( a:1..3, b:'a'..'c' ) .collect() == [ [ a:1, b:'a' ], [ a:1, b:'b' ], [ a:1, b:'c' ], [ a:2, b:'a' ], [ a:2, b:'b' ], [ a:2, b:'c' ], [ a:3, b:'a' ], [ a:3, b:'b' ], [ a:3, b:'c' ] ]
K
- They type of the Map keys.V
- The type of the Iterable value.map
- The map of Iterables.Stream
wrapping a MapIterator
.public static <T> Stream<T> from(Stream<T> stream)
Stream
from another Stream
.
import groovy.stream.* assert Stream.from( Stream.from( 1..3 ) ) .collect() == [ 1, 2, 3 ]
T
- The type of the Stream.stream
- The other Stream
.Stream
wrapping the iterator of the other Stream
.public static <T> Stream<T> from(Iterable<T> iterable)
Stream
from an Iterable
.
import groovy.stream.* assert Stream.from( [ 1, 2, 3 ] ) .collect() == [ 1, 2, 3 ]
T
- The type of the Iterable.iterable
- The iterable to iterate.Stream
wrapping the iterable.iterator()
.public static <T> Stream<T> from(Iterator<T> iterator)
Stream
from an Iterator
.
import groovy.stream.* assert Stream.from( [ 1, 2, 3 ].iterator() ) .collect() == [ 1, 2, 3 ]
T
- The type of the Iterator.iterator
- The iterator to wrap.Stream
wrapping the iterator.public static Stream<String> from(BufferedReader reader)
Stream
from a BufferedReader
that iterates the lines in it.reader
- The Reader to iterate lines fromStream
wrapping a BufferedReaderIterator
.public static Stream<ZipEntry> from(ZipFile file)
file
- the ZipFile to iterate ZipEntrys from.Stream
wrapping an EnumerationIterator
.public static Stream<JarEntry> from(JarFile file)
file
- the JarFile to iterate JarEntrys from.Stream
wrapping an EnumerationIterator
.public static <T> Stream<T> from(Closure<T> closure)
Stream
that for every element, returns the result of calling the Closure
.T
- The type of the return value from the Closure.closure
- The closure to call each time an element is requested.Stream
wrapping an RepeatingClosureIterator
.public static <T> Stream<T> from(T object)
Stream
that for every element, returns object
.
import groovy.stream.* assert Stream.from( 1 ).take( 3 ).collect() == [ 1, 1, 1 ]
T
- The type of the Object
.object
- The object to return each time an element is requested.Stream
wrapping an RepeatingObjectIterator
.public static <T> Stream<T> from(T[] array)
Stream
that iterates every Object
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* String[] elems = [ 'one', 'two', 'three' ] assert Stream.from( elems ).collect() == [ 'one', 'two', 'three' ]
T
- The type of the array.array
- An array of Object to iterateStream
wrapping the iterator for the array as a List.public static Stream<Byte> from(byte[] array)
Stream
that iterates every byte
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* byte[] elems = [ 127, 128, 129 ] assert Stream.from( elems ).collect() == [ 127, -128, -127 ]
array
- An array of byte to iterateStream
wrapping the iterator for the array as a List.public static Stream<Character> from(char[] array)
Stream
that iterates every Character
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* char[] elems = 'Hello'.toList() assert Stream.from( elems ).collect() == [ 'H', 'e', 'l', 'l', 'o' ]
array
- An array of char to iterateStream
wrapping the iterator for the array as a List.public static Stream<Short> from(short[] array)
Stream
that iterates every Short
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* short[] elems = [ 10, 65535, 65536, 65537, 99 ] assert Stream.from( elems ).collect() == [ 10, -1, 0, 1, 99 ]
array
- An array of short to iterateStream
wrapping the iterator for the array as a List.public static Stream<Integer> from(int[] array)
Stream
that iterates every Integer
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* int[] elems = [ 10, 65535, 65536, 65537, 99 ] assert Stream.from( elems ).collect() == [ 10, 65535, 65536, 65537, 99 ]
array
- An array of int to iterateStream
wrapping the iterator for the array as a List.public static Stream<Long> from(long[] array)
Stream
that iterates every Long
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* long[] elems = [ 10, 65535, 65536, 65537, 99 ] assert Stream.from( elems ).collect() == [ 10, 65535, 65536, 65537, 99 ]
array
- An array of long to iterateStream
wrapping the iterator for the array as a List.public static Stream<Float> from(float[] array)
Stream
that iterates every Float
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* float[] elems = [ 0.1, 0.2, 0.3 ] assert Stream.from( elems ).collect() == [ 0.1f, 0.2f, 0.3f ]
array
- An array of float to iterateStream
wrapping the iterator for the array as a List.public static Stream<Double> from(double[] array)
Stream
that iterates every Double
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* double[] elems = [ 0.1, 0.2, 0.3 ] assert Stream.from( elems ).collect() == [ 0.1, 0.2, 0.3 ]
array
- An array of double to iterateStream
wrapping the iterator for the array as a List.public static Stream<Boolean> from(boolean[] array)
Stream
that iterates every Boolean
in an array. First converts the array to an ArrayList
, then wraps the ArrayList.iterator()
.
import groovy.stream.* boolean[] elems = [ true, false ] assert Stream.from( elems ).collect() == [ true, false ]
array
- An array of boolean to iterateStream
wrapping the iterator for the array as a List.