|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.collections.stream.Streams
public class Streams
Class methods for creating very simple Streams wrapping existing
classes from the Java collections framework, specifiying its elements and
| Method Summary | ||
|---|---|---|
static
|
cons(A... elements)
Creates a new Stream that retrieves the elements from the given
array. |
|
static
|
cons(A element)
Creates a new Stream that will retrieve just the given element |
|
static
|
cons(A head,
Stream<? extends A> tail)
Creates a new Stream that retrieves elements from a head, and
another Iterable, called tail. |
|
static
|
cons(Thunk<A> element)
Creates a one-element new Stream that will retrieve the thunk's value. |
|
static
|
cons(Thunk<A> head,
Stream<? extends A> tail)
Creates a new Stream that retrieves elements from a head's thunk,
and another Iterable, called tail. |
|
static
|
empty()
Answers a Stream that has no elements. |
|
static Stream<Integer> |
enumerate(int start)
Iterates from the starting integer, adding 1. |
|
static Stream<Integer> |
enumerate(int start,
int stop)
Iterates from the start integer, by adding 1, up to the
stop integer, inclusive. |
|
static Stream<Integer> |
enumerate(int start,
int stop,
int step)
Iterates from the start integer, by adding step, up to the
stop integer, inclusive. |
|
static
|
from(A[] elements)
Creates a new Stream that retrieves the elements from the given
array. |
|
static Stream<Character> |
from(CharSequence charSequence)
Creates a new Stream that retrieves character elements from the
given charSequence |
|
static
|
from(Collection<? extends A> collection)
Creates a new Stream that will retrieve elements from the given
collection |
|
static
|
from(Deque<? extends A> list)
Creates a new Stream that retrieves elements from a Deque. |
|
static
|
from(Enumeration<? extends A> enumeration)
Creates a new Stream that retrieves elements from the given
Enumeration. |
|
static
|
from(Iterable<? extends A> iterable)
Create a new Stream that retrieves elements from the given
Iterable. |
|
static
|
from(Iterator<? extends A> iterator)
Creates a new Stream that retrieves elements from the given
iterator. |
|
static
|
from(List<? extends A> list)
Creates a new Stream that retrieves elements from a list. |
|
static
|
iterate(A seed,
Applicable<? super A,? extends A> generator)
Creates a new infinite Stream that retrieves element from the
sequence where the nth element is the given function applied to the nth-1. |
|
static
|
iterateUntilNull(A seed,
Applicable<? super A,? extends A> generator)
Creates a new, potentially infinte Stream that iterates over the
given seed and generator, but will stop before any retrieved element would be
null. |
|
static
|
repeat(A element)
Answers an infinite Stream that indefinitely retrieves the given element. |
|
static
|
repeat(Thunk<A> thunk)
Answers an infinite Stream that indefinitely retrieves the given thunk's value. |
|
static
|
type()
Answers the Stream class, but preserving its element generic type. |
|
static
|
undefined()
Answers a one element Stream that throws an exception when trying
to access its element. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
@Projection
@Conditionally(value=Repeatable.class)
public static <A> Stream<A> cons(Thunk<A> head,
@NonNull
Stream<? extends A> tail)
Stream that retrieves elements from a head's thunk,
and another Iterable, called tail.
This operation is known and cons(tructing), and can be undone by
sending Stream.delayedDecons() to the resulting Stream.
The returned stream is Repeatable as long as the thunk's head value
is always equal, and the tail is repeatable.
A - head - tail -
Stream
@Projection
@Conditionally(value=Repeatable.class)
public static <A> Stream<A> cons(A head,
@NonNull
Stream<? extends A> tail)
Stream that retrieves elements from a head, and
another Iterable, called tail.
This operation is known and cons(tructing), and can be undone by
sending Stream.decons() to the resulting Stream.
* The returned stream is Repeatable as long as the tail is
repeatable.
A - head - tail -
Stream
@Repeatable
@Projection
public static <A> Stream<A> cons(@NonNull
A... elements)
Stream that retrieves the elements from the given
array. This stream permits efficient random access and grants repeatable
iteration order.
A - the element typeelements - the array that is Stream source
@Projection @Repeatable public static <A> Stream<A> cons(Thunk<A> element)
Repeatable as long as the thunk's value is always
equal.
A - element -
Thunk.value()@Repeatable @Projection public static <A> Stream<A> cons(A element)
A - element - the single element the new Stream will retrieve
Stream
@Projection
public static <A> Stream<A> iterate(@NonNull
A seed,
@NonNull
Applicable<? super A,? extends A> generator)
Stream that retrieves element from the
sequence where the nth element is the given function applied to the nth-1.
If function is side-effect-free, the following sequence is generated:
[seed, generator(seed), generator(generator(seed)), generator(generator(generator(seed))), ...]
A - seed - the first value to be retrievedgenerator - a function used to generated each element from the sequence after
the initial element
Stream that iterates over over the generated values@Projection public static Stream<Integer> enumerate(int start)
[start, start+1, start+2...]
start - the initial element of the sequence
[start, start+1, start+2...]
@Projection
public static Stream<Integer> enumerate(int start,
int stop)
start integer, by adding 1, up to the
stop integer, inclusive. This generates the finite stream
[start, start+1, start+2..., stop]
start - the initial element of the sequencestop - the final element of the sequence
[start, start+1, start+2..., stop]. As a particular case,
if start == stop, the sequence [start] is retrieved. If
start > stop, an empty stream is retrieved
@Projection
public static Stream<Integer> enumerate(int start,
int stop,
int step)
start integer, by adding step, up to the
stop integer, inclusive. This generates the finite stream
[start, start+step, start+2*step..., stop]
start - the initial element of the sequencestop - the final element of the sequencestep -
[start, start+step, start+2*step..., stop]. As a particular
case, if start == stop, the sequence [start] is retrieved.
If start > stop, an empty stream is retrieved
@Projection
public static <A> Stream<A> iterateUntilNull(@NonNull
A seed,
@NonNull
Applicable<? super A,? extends A> generator)
Stream that iterates over the
given seed and generator, but will stop before any retrieved element would be
null.
A - seed - the first value to be retrievedgenerator - a function used to generated each element from the sequence after
the initial element
Stream that iterates over over the generated values,
until an element is null.@Projection public static <A> Stream<A> repeat(A element)
A - element -
Stream that repeats the given element
@Projection
public static <A> Stream<A> repeat(@NonNull
Thunk<A> thunk)
A - thunk - the Thunk whose value to repeat
Stream
@Repeatable
@Projection
public static <A> Stream<A> from(@NonNull
A[] elements)
Stream that retrieves the elements from the given
array. Equivalent to cons(Object...)
A - the element typeelements - the array that is Stream source
@Projection
@Conditionally(value=Repeatable.class)
public static <A> Stream<A> from(@NonNull
Iterable<? extends A> iterable)
Stream that retrieves elements from the given
Iterable.
A - the element typeiterable - the Iterable to decorate
Stream, a new stream that
wraps it, otherwise
@Projection
public static <A> Stream<A> from(@NonNull
Iterator<? extends A> iterator)
Stream that retrieves elements from the given
iterator. The resulting stream can not be iterated more than once, thus it
is inherently mutable
A - iterator - source of the the new Stream
Stream
@Projection
public static <A> Stream<A> from(@NonNull
Enumeration<? extends A> enumeration)
Stream that retrieves elements from the given
Enumeration. The resulting stream can not be iterated more than
once, thus it is inherently mutable
A - enumeration - source of the new Stream
Stream
@Repeatable
@Projection
public static Stream<Character> from(@NonNull
CharSequence charSequence)
Stream that retrieves character elements from the
given charSequence
charSequence - source of the of characters of the new Stream
Stream
@Repeatable
@Projection
public static <A> Stream<A> from(@NonNull
Collection<? extends A> collection)
Stream that will retrieve elements from the given
collection
A - collection - source of the new Stream
Stream
@Repeatable
@Projection
public static <A> Stream<A> from(@NonNull
List<? extends A> list)
Stream that retrieves elements from a list. This
streams grants repeatable iterator order and supports (not necessary
efficient) random access by index.
A - the element typelist - the source of the new Stream
Stream
@NonNull
@Repeatable
@Projection
public static <A> Stream<A> from(@NonNull
Deque<? extends A> list)
Stream that retrieves elements from a Deque.
This streams grants repeatable iterator order and supports (not necessary
efficient) random access by index. This stream can be lazily reversed.
A - the element typelist - the source of the new Stream
Stream@Constant @Repeatable public static <A> Stream<A> empty()
Stream that has no elements. This stream is immutable and
singleton
A - the element type
Stream@Constant public static <A> Stream<A> undefined()
Stream that throws an exception when trying
to access its element.
A -
@Constant public static <A> Class<Stream<A>> type()
lambda($(Streams.<User> type()).toList())
A -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||