|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.AbstractProtoMonad<Stream<A>,Stream,A>
net.sf.staccatocommons.collections.stream.AbstractBasicStream<A>
A - public abstract class AbstractBasicStream<A>
Very minimal stream partial implementation that defines final methods that are, by spec, overloading or synonyms of the other stream methods
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface net.sf.staccatocommons.collections.stream.Stream |
|---|
Stream.DeconsApplicable<A,B>, Stream.DelayedDeconsApplicable<A,B>, Stream.EmptyApplicable<A> |
| Constructor Summary | |
|---|---|
AbstractBasicStream()
|
|
| Method Summary | ||
|---|---|---|
A |
any()
Returns the Stream.head() of this Stream
The different between Stream.head() and Stream.any() is strictly semantic:
use this message instead of Stream.head() whenever the code needs an
unspecified element, rather than the first element of the stream. |
|
Stream<A> |
append(Iterable<A> other)
Equivalent to Stream.concat(Iterable) |
|
Stream<A> |
append(Thunk<A> element)
Equivalent to Stream.delayedAppend(Thunk). |
|
boolean |
equiv(A... elements)
Test that the elements of this stream are equal to the elements of the given array, and in the same order. |
|
boolean |
equiv(Iterator<? extends A> other)
Test that the elements of this stream are equal to the elements of the given iterator, and in the same order. |
|
boolean |
equivBy(Evaluable2<? super A,? super A> equalityTest,
A... elements)
Test that the elements of this stream are equivalent to the given elements, and in the same order, using the given
equalityTest for determining equivalence between elements. |
|
boolean |
equivBy(Evaluable2<? super A,? super A> equalityTest,
Iterator<? extends A> other)
Test that the elements of this stream are equivalent to the elements of the given Iterable, and in the same order, using the given
equalityTest for determining equivalence between elements. |
|
|
equivOn(Applicable<? super A,? extends B> function,
A... elements)
Test that the elements of this stream are equivalent to the given elements, and in the same order, using the Equiv.on(function) for
determining equivalence between elements. |
|
|
equivOn(Applicable<? super A,? extends B> function,
Iterable<? extends A> iterable)
Test that the elements of this stream are equivalent to the elements of the given Iterable, and in the same order, using the
Equiv.on(function) for determining equivalence between
elements. |
|
|
equivOn(Applicable<? super A,? extends B> function,
Iterator<? extends A> other)
Test that the elements of this stream are equivalent to the elements of the given Iterator, and in the same order, using the
Equiv.on(function) for determining equivalence between
elements. |
|
int |
findPosition(Evaluable<? super A> predicate)
Answers the zero-based index of first, present element that matches the given predicate. |
|
A |
first()
Answers the first element. |
|
|
map(Applicable<? super A,? extends B> function)
Transforms each element using the given function |
|
|
maximumOn(Applicable<? super A,B> function)
Answers the maximum element of the stream, using the given Compare.on(function) to compare elements. |
|
Stream<A> |
memorize()
Equivalent to Stream.memoize() |
|
|
minimumOn(Applicable<? super A,B> function)
Answers the minimum element of the stream, using the given Compare.on(function) to compare elements. |
|
int |
positionOf(A element)
Answers the index of the given present element. |
|
Stream<A> |
prepend(Thunk<A> element)
Equivalent to Stream.delayedPrepend(Thunk) |
|
void |
println()
Prints the stream elements to System.out, followed by a newline
character. |
|
A |
second()
Answers the second element. |
|
|
sortOn(Applicable<? super A,B> function)
Sorts this Stream, using Compare.on(function) as comparator |
|
A |
third()
Answers the third element. |
|
|
zip(B... elements)
Returns a Stream formed by by pair of element from
this and the given elements. |
|
|
zip(Iterable<B> iterable)
Returns a Stream formed by by pair of element from
this and the given iterable. |
|
|
zip(Iterable<B> iterable,
Function2<? super A,? super B,C> function)
Equivalent to Stream.zipWith(Function2, Iterable), with arguments
interchanged |
|
|
zip(Iterator<B> other)
Returns a Stream formed by by pair of element from
this and the given Iterator. |
|
| Methods inherited from class net.sf.staccatocommons.lang.AbstractProtoMonad |
|---|
each, replace, replaceNull, skip, skipNull |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.sf.staccatocommons.defs.partial.ContainsAware |
|---|
contains |
| Methods inherited from interface net.sf.staccatocommons.defs.ProtoMonad |
|---|
replace, replaceNull, skipNull |
| Methods inherited from interface net.sf.staccatocommons.defs.partial.SizeAware |
|---|
isEmpty, size |
| Constructor Detail |
|---|
public AbstractBasicStream()
| Method Detail |
|---|
public final A any()
StreamStream.head() of this Stream
The different between Stream.head() and Stream.any() is strictly semantic:
use this message instead of Stream.head() whenever the code needs an
unspecified element, rather than the first element of the stream.
any in interface Stream<A>Stream.head()public final A first()
StreamStream.head().
It is also equivalent to get(0), but throws a
EmptySourceException if stream is empty
first in interface Stream<A>Stream.head()public final A second()
Streamget(1), but
throws a NoSuchElementException if stream size < 2
second in interface Stream<A>get(1)public final A third()
Streamget(2), but throws
a NoSuchElementException if stream size < 3
third in interface Stream<A>get(2)public final <B> Stream<B> map(Applicable<? super A,? extends B> function)
Stream
map in interface Stream<A>map in interface ProtoMonad<Stream<A>,Stream,A>function - the mapper used to transform each element, applying it
Stream projection that will retrieve the result of
applying the given function to each elementpublic final boolean equiv(A... elements)
Stream
equiv in interface Stream<A>true if this stream has the same number of elements
that the given array, and each pair formed by elements of this
stream and the given array at same position are equal.
false otherwise
public final boolean equivBy(Evaluable2<? super A,? super A> equalityTest,
A... elements)
Streamelements, and in the same order, using the given
equalityTest for determining equivalence between elements.
equivBy in interface Stream<A>true if this stream has the same number of elements
that the given elements, and each pair formed by
elements of this stream and given elements at same
position satisfies the given Evaluable2
public final <B> boolean equivOn(Applicable<? super A,? extends B> function,
A... elements)
StreamEquiv.on(function) for
determining equivalence between elements.
equivOn in interface Stream<A>true if this stream has the same number of elements
that the given elements, and each pair formed by
elements of this stream and the given elements at same
position satisfies the Evaluable2
Equiv.on(function)public final boolean equiv(Iterator<? extends A> other)
Streamiterator, and in the same order.
equiv in interface Stream<A>other, and each pair formed by elements of this
stream and given iterable at same position are equal.
false otherwise
public final boolean equivBy(Evaluable2<? super A,? super A> equalityTest,
Iterator<? extends A> other)
StreamIterable, and in the same order, using the given
equalityTest for determining equivalence between elements.
equivBy in interface Stream<A>true if this stream has the same number of elements
that other, and each pair formed by
elements of this stream and other at same
position satisfies the given Evaluable2
public final <B> boolean equivOn(Applicable<? super A,? extends B> function,
Iterator<? extends A> other)
StreamIterator, and in the same order, using the
Equiv.on(function) for determining equivalence between
elements.
equivOn in interface Stream<A>true if this stream has the same number of elements
that the given Iterator, and each pair formed by
elements of this stream and given Iterator at same
position satisfies the Evaluable2
Equiv.on(function)public final <B> Stream<Tuple2<A,B>> zip(B... elements)
StreamStream formed by by pair of element from
this and the given elements.
If either this or the given array is shorter than the other
one, the remaining elements are discarded.
Examples:
//Answers the stream [(0, a), (1,b), (2,c)]
Streams.cons(0, 1, 2).zip('a', 'b', 'c');
//Answers true
Streams
.from("hello")
.zip(Streams.from("world!"))
.equiv(
_('h', 'w'),
_('e', 'o'),
_('l', 'r'),
_('l', 'l'),
_('o', 'd')); //notice the last '!' was discarded
zip in interface Stream<A>Applicable2 to each
pair this Stream and the given elements. The resulting Stream size
is the minimum of both iterables sizes.Stream.zip(Iterable, Function2)public final <B> Stream<Tuple2<A,B>> zip(Iterator<B> other)
StreamStream formed by by pair of element from
this and the given Iterator.
If either this or other is shorter than
the other one, the remaining elements are discarded.
zip in interface Stream<A>Applicable2 to each
pair this Stream and the given iterator. The resulting Stream size
is the minimum of both iterables sizes, or infinite, if both this
and other areIterables.zip(Iterable, Iterable),
Stream.zip(Iterable, Function2)public final <B> Stream<Tuple2<A,B>> zip(Iterable<B> iterable)
StreamStream formed by by pair of element from
this and the given iterable.
If either this or the given iterable is shorter than
the other one, the remaining elements are discarded.
zip in interface Stream<A>Applicable2 to each
pair this Stream and the given iterable. The resulting Stream size
is the minimum of both iterables sizes, or infinite, if both this
and iterable areIterables.zip(Iterable, Iterable),
Stream.zip(Iterable, Function2)public final int findPosition(Evaluable<? super A> predicate)
StreamStream.findIndex(Evaluable), with the only difference that it will throw
a NoSuchElementException if the given element is not present on the
stream
findPosition in interface Stream<A>predicatepublic final int positionOf(A element)
StreamStream.indexOf(Object), with the only
difference that it will throw a NoSuchElementException if the given
element is not present on the stream
positionOf in interface Stream<A>
public final <B extends Comparable<B>> A maximumOn(Applicable<? super A,B> function)
throws NoSuchElementException
StreamCompare.on(function) to compare elements.
maximumOn in interface Stream<A>EmptySourceException - if the stream is empty.
NoSuchElementException
public final <B extends Comparable<B>> A minimumOn(Applicable<? super A,B> function)
throws NoSuchElementException
StreamCompare.on(function) to compare elements.
minimumOn in interface Stream<A>EmptySourceException - if the stream is empty.
NoSuchElementException
public final <B> boolean equivOn(Applicable<? super A,? extends B> function,
Iterable<? extends A> iterable)
StreamIterable, and in the same order, using the
Equiv.on(function) for determining equivalence between
elements.
equivOn in interface Stream<A>true if this stream has the same number of elements
that the given iterable, and each pair formed by
elements of this stream and given iterable at same
position satisfies the Evaluable2
Equiv.on(function)public final <B extends Comparable<B>> Stream<A> sortOn(Applicable<? super A,B> function)
StreamCompare.on(function) as comparator
sortOn in interface Stream<A>Streampublic final void println()
StreamSystem.out, followed by a newline
character. Equivalent to println(System.out)
println in interface Stream<A>public final Stream<A> memorize()
StreamStream.memoize()
memorize in interface Stream<A>public Stream<A> append(Iterable<A> other)
StreamStream.concat(Iterable)
append in interface Stream<A>public final Stream<A> append(Thunk<A> element)
StreamStream.delayedAppend(Thunk).
append in interface Stream<A>public final Stream<A> prepend(Thunk<A> element)
StreamStream.delayedPrepend(Thunk)
prepend in interface Stream<A>
public final <B,C> Stream<C> zip(@NonNull
Iterable<B> iterable,
@NonNull
Function2<? super A,? super B,C> function)
StreamStream.zipWith(Function2, Iterable), with arguments
interchanged
zip in interface Stream<A>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||