T
- the element typepublic class Ix<T>
extends java.lang.Object
implements java.lang.Iterable<T>
This builder is the dual of the
Observable
class.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Iterable<T> |
it
The backing iterable.
|
Modifier | Constructor and Description |
---|---|
protected |
Ix(java.lang.Iterable<T> source)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<U,V> Ix<V> |
aggregate(rx.functions.Func2<? super U,? super T,? extends U> sum,
rx.functions.Func2<? super U,? super java.lang.Integer,? extends V> divide)
Creates an iterable which traverses the source iterable and maintains a running sum value based
on the
sum function parameter. |
Ix<java.lang.Boolean> |
all(rx.functions.Func1<? super T,java.lang.Boolean> predicate)
Returns an iterable which contains true if all
elements of the source iterable satisfy the predicate.
|
Ix<java.lang.Boolean> |
any()
Determines if the given source has any elements at all.
|
Ix<java.lang.Boolean> |
any(rx.functions.Func1<? super T,java.lang.Boolean> predicate)
Tests if there is any element of the source that satisfies the given predicate function.
|
<V extends java.lang.Comparable<? super V>> |
argAndMax(rx.functions.Func1<? super T,? extends V> valueSelector)
Returns a pair of the maximum argument and value from the given sequence.
|
<V> Pair<T,V> |
argAndMax(rx.functions.Func1<? super T,? extends V> valueSelector,
java.util.Comparator<? super V> valueComparator)
Returns a pair of the maximum argument and value from the given sequence.
|
<V extends java.lang.Comparable<? super V>> |
argAndMin(rx.functions.Func1<? super T,? extends V> valueSelector)
Returns a pair of the minimum argument and value from the given sequence.
|
<V> Pair<T,V> |
argAndMin(rx.functions.Func1<? super T,? extends V> valueSelector,
java.util.Comparator<? super V> valueComparator)
Returns a pair of the minimum argument and value from the given sequence.
|
Ix<java.math.BigDecimal> |
averageBigDecimal()
Computes and signals the average value of the BigDecimal source.
|
Ix<java.math.BigDecimal> |
averageBigInteger()
Computes and signals the average value of the BigInteger source.
|
Ix<java.lang.Double> |
averageDouble()
Computes and signals the average value of the Double source.
|
Ix<java.lang.Float> |
averageFloat()
Computes and signals the average value of the Float source.
|
Ix<java.lang.Double> |
averageInt()
Computes and signals the average value of the integer source.
|
Ix<java.lang.Double> |
averageLong()
Computes and signals the average value of the Long source.
|
Ix<java.util.List<T>> |
buffer(int bufferSize)
Returns an iterable which buffers the source elements
into
bufferSize lists. |
<C> Ix<C> |
collect(rx.functions.Func0<C> collectionSupplier,
rx.functions.Action2<C,? super T> collector)
Collects all values from this sequence into a custom collection via the collector
action and returns the collection as a single element.
|
static <T> Ix<T> |
concat(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> sources)
Creates an iterable builder which contains the concatenation
of all the iterables returned by the iterable.
|
static <T> Ix<T> |
concat(java.lang.Iterable<? extends T>... sources)
Concatenates the array of Iterable sources into a single Iterable sequence.
|
Ix<T> |
concatWith(java.lang.Iterable<? extends T> other)
Concatenate this iterable with the other iterable in a way, that calling the second
iterator()
only happens when there is no more element in the first iterator. |
Ix<T> |
concatWith(T... values)
Concatenate this iterable with the sequence of array values.
|
Ix<T> |
concatWithAll(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> others)
Creates an iterable builder which contains the concatenation
of this iterable and the rest iterable provided.
|
Ix<java.lang.Boolean> |
contains(java.lang.Object value)
Returns an iterable which checks for the existence of the supplied
value by comparing the elements of the source iterable using reference
and
equals() . |
Ix<java.lang.Integer> |
count()
Counts the elements of the iterable source by using a 32 bit
int . |
Ix<java.lang.Long> |
countLong()
Counts the elements of the iterable source by using a 64 bit
long . |
static <T> Ix<T> |
defer(rx.functions.Func0<? extends java.lang.Iterable<T>> func)
Defers the source iterable creation to registration time and
calls the given
func for the actual source. |
Ix<T> |
dematerialize()
Convert the source materialized elements into normal iterator behavior.
|
Ix<T> |
distinct()
Returns an iterable which filters its elements based if they vere ever seen before in
the current iteration.
|
<U> Ix<T> |
distinct(rx.functions.Func1<? super T,? extends U> keySelector)
Returns an iterable which filters its elements by an unique key
in a way that when multiple source items produce the same key, only
the first one ever seen gets relayed further on.
|
Ix<T> |
distinctNext()
Creates an iterable which ensures that subsequent values of T are not equal
(reference and equals).
|
<U> Ix<T> |
distinctNext(rx.functions.Func1<T,U> keySelector)
Creates an iterable which ensures that subsequent values of
T are not equal in respect to the extracted keys (reference and equals).
|
Ix<T> |
doOnCompleted(rx.functions.Action0 action)
Returns an iterable which executes the given action after
the stream completes.
|
Ix<T> |
doOnNext(rx.functions.Action1<? super T> action)
Construct a new iterable which will invoke the specified action
before the source value gets relayed through it.
|
Ix<T> |
doWhile(rx.functions.Func0<java.lang.Boolean> gate)
Returns an iterable which reiterates over and over again on
source
as long as the gate is true. |
static <T> Ix<T> |
empty()
Returns an empty iterable which will not produce elements.
|
Ix<T> |
endWith(T value)
Creates an iterable sequence which returns all elements from source
followed by the supplied value as last.
|
static <T> Ix<T> |
error(java.lang.Throwable t)
Returns an iterator which will throw the given
Throwable exception when the client invokes
next() the first time. |
Ix<T> |
filter(rx.functions.Func1<? super T,java.lang.Boolean> predicate)
Creates an iterable which filters this iterable with the
given predicate factory function.
|
Ix<T> |
filterIndexed(rx.functions.Func2<java.lang.Integer,? super T,java.lang.Boolean> predicate)
Creates an iterable which filters this iterable with the
given predicate factory function.
|
T |
first()
Returns the first element from the iterable sequence or
throws a NoSuchElementException.
|
T |
firstOrDefault(T defaultValue)
Returns the first element from the sequence or the default
value if this sequence is empty
|
<U> Ix<U> |
flatMap(rx.functions.Func1<? super T,? extends java.lang.Iterable<? extends U>> selector)
Creates an iterable which returns a stream of Us for each source Ts.
|
void |
forEach(rx.functions.Action1<? super T> action)
Iterate over the source and submit each value to the
given action.
|
static <T> Ix<T> |
from(java.lang.Iterable<T> source)
Creates a new iterable builder instance by wrapping the given
source sequence, if not already a builder.
|
static <T> Ix<T> |
from(rx.Observable<T> source)
Creates a new iterable builder by wrapping the given observable.
|
static <T> Ix<T> |
from(T... ts)
Creates a new iterable builder instance by wrapping the given
array.
|
static <T> Ix<T> |
fromPart(int from,
int to,
T... ts)
Creates a new iterable builder instance by wrapping the given
array.
|
static <T> Ix<T> |
generate(T seed,
rx.functions.Func1<? super T,java.lang.Boolean> predicate,
rx.functions.Func1<? super T,? extends T> next)
A generator function which returns Ts based on the termination condition and the way it computes the next values.
|
<K> Ix<GroupedIterable<K,T>> |
groupBy(rx.functions.Func1<? super T,? extends K> keySelector)
Creates an iterable which traverses the source iterable,
and based on the key selector, groups values the elements into GroupedIterables,
which can be interated over later on.
|
<K,V> Ix<GroupedIterable<K,V>> |
groupBy(rx.functions.Func1<? super T,? extends K> keySelector,
rx.functions.Func1<? super T,? extends V> valueSelector)
Creates an iterable which traverses the source iterable,
and based on the key selector, groups values extracted by valueSelector into GroupedIterables,
which can be interated over later on.
|
<U extends java.util.Collection<? super T>> |
into(U out)
Add the elements of the sequence into the supplied collection.
|
Ix<java.lang.Boolean> |
isEmpty()
Returns a single true if the target iterable is empty.
|
java.util.Iterator<T> |
iterator() |
Ix<java.lang.String> |
join(java.lang.String separator)
Concatenates the source strings one after another and uses the given separator.
|
static <T> Ix<T> |
just(T value)
Creates an iterable which returns only a single element.
|
T |
last()
Returns the last element of the iterable or throws a
NoSuchElementException if the iterable is empty. |
T |
lastOrDefault(T defaultValue)
Returns the last element of this sequence or the default value if
this sequence is empty.
|
<U> Ix<U> |
map(rx.functions.Func1<? super T,? extends U> selector)
Creates an iterable which is a transforms the source
elements by using the selector function.
|
<U> Ix<U> |
mapIndexed(rx.functions.Func2<java.lang.Integer,? super T,? extends U> selector)
Creates an iterable which is a transforms the source
elements by using the selector function.
|
Ix<rx.Notification<T>> |
materialize()
Transforms the sequence of the source iterable into an option sequence of
Option.some(), Option.none() and Option.error() values, depending on
what the source's hasNext() and next() produces.
|
<U extends java.lang.Comparable<? super U>> |
max()
Returns the maximum value of the given iterable source.
|
Ix<T> |
max(java.util.Comparator<? super T> comparator)
Returns the maximum value of the given iterable source in respect to the supplied comparator.
|
<U extends java.lang.Comparable<? super U>> |
maxBy()
Returns an iterator which will produce a single List of the maximum values encountered
in the source stream based on the supplied key selector.
|
Ix<java.util.List<T>> |
maxBy(java.util.Comparator<? super T> comparator)
Returns an iterator which will produce a single List of the maximum values encountered
in the source stream based on the supplied comparator.
|
<U extends java.lang.Comparable<? super U>> |
mayBy(rx.functions.Func1<? super T,U> keySelector)
Returns an iterator which will produce a single List of the maximum values encountered
in the source stream based on the supplied key selector.
|
<U> Ix<java.util.List<T>> |
mayBy(rx.functions.Func1<? super T,U> keySelector,
java.util.Comparator<? super U> keyComparator)
Returns an iterator which will produce a single List of the minimum values encountered
in the source stream based on the supplied key selector and comparator.
|
Ix<T> |
memoize(int bufferSize)
Enumerates the source iterable once and caches its results.
|
Ix<T> |
memoizeAll()
The returned iterable ensures that the source iterable is only traversed once, regardless of
how many iterator attaches to it and each iterator see only the values.
|
<U extends java.lang.Comparable<? super U>> |
min()
Returns the maximum value of the given iterable source.
|
Ix<T> |
min(java.util.Comparator<? super T> comparator)
Returns the minimum value of the given iterable source in respect to the supplied comparator.
|
Ix<java.util.List<T>> |
minBy(java.util.Comparator<? super T> comparator)
Returns an iterator which will produce a single List of the minimum values encountered
in the source stream based on the supplied comparator.
|
<U extends java.lang.Comparable<? super U>> |
minBy(rx.functions.Func1<? super T,U> keySelector)
Returns an iterator which will produce a single List of the minimum values encountered
in the source stream based on the supplied key selector.
|
<U> Ix<java.util.List<T>> |
minBy(rx.functions.Func1<? super T,U> keySelector,
java.util.Comparator<? super U> keyComparator)
Returns an iterator which will produce a single List of the minimum values encountered
in the source stream based on the supplied key selector and comparator.
|
<U extends java.lang.Comparable<? super U>> |
minxBy()
Returns an iterator which will produce a single List of the minimum values encountered
in the source stream based on the supplied key selector.
|
static <T> Ix<T> |
newBuilder(java.lang.Iterable<T> source)
Creates a new iterable builder instance by wrapping the given
source sequence.
|
<U> Ix<U> |
ofType(java.lang.Class<U> token)
Casts the source iterable into a different typ by using a type token.
|
<U extends java.lang.Comparable<? super U>> |
orderBy()
Returns an iterable which traverses the entire
source iterable and creates an ordered list
of elements.
|
Ix<T> |
orderBy(java.util.Comparator<? super T> comparator)
Returns an iterable which traverses the entire
source iterable and creates an ordered list
of elements.
|
<U extends java.lang.Comparable<? super U>> |
orderBy(rx.functions.Func1<? super T,? extends U> keySelector)
Returns an iterable which traverses the entire
source iterable and creates an ordered list
of elements.
|
<U> Ix<T> |
orderBy(rx.functions.Func1<? super T,? extends U> keySelector,
java.util.Comparator<? super U> keyComparator)
Returns an iterable which traverses the entire
source iterable and creates an ordered list
of elements.
|
void |
print()
Runs this iterable and prints the values.
|
void |
println()
Runs this iterable and prints the values.
|
<U> Ix<U> |
prune(rx.functions.Func1<? super java.lang.Iterable<? extends T>,? extends java.lang.Iterable<U>> func)
Applies the
func function for a shared instance of the source,
e.g., func.invoke(share(source)) . |
<U> Ix<U> |
publish(rx.functions.Func1<? super java.lang.Iterable<? super T>,? extends java.lang.Iterable<? extends U>> func,
U initial)
The returned iterable ensures that the source iterable is only traversed once, regardless of
how many iterator attaches to it and each iterator see only the same cached values.
|
<U> Ix<U> |
publish(rx.functions.Func1<? super java.lang.Iterable<T>,? extends java.lang.Iterable<U>> func)
The returned iterable ensures that the source iterable is only traversed once, regardless of
how many iterator attaches to it and each iterator see only the values.
|
static Ix<java.lang.Integer> |
range(int start,
int count)
Creates an integer iteratable builder which returns numbers from the start position in the count size.
|
static Ix<java.lang.Long> |
range(long start,
long count)
Creates an long iterable builder which returns numbers from the start position in the count size.
|
Ix<T> |
reduce(rx.functions.Func2<T,T,T> reducer)
Reduces the values of this sequence into a single value by using a
reducer function.
|
void |
removeAll()
Consumes the sequence and removes all items via the Iterator.remove().
|
static <T> Ix<T> |
repeat(T t)
Creates an iterable builder which repeats the given
value indefinitely.
|
static <T> Ix<T> |
repeat(T t,
int count)
Returns an iterable builder which repeats the given single value the specified number of times.
|
<U> Ix<U> |
replay(rx.functions.Func1<? super java.lang.Iterable<T>,? extends java.lang.Iterable<U>> func)
The returned iterable ensures that the source iterable is only traversed once, regardless of
how many iterator attaches to it and each iterator may only see one source element.
|
<U> Ix<U> |
replay(rx.functions.Func1<? super java.lang.Iterable<T>,? extends java.lang.Iterable<U>> func,
int bufferSize)
The returned iterable ensures that the source iterable is only traversed once, regardless of
how many iterator attaches to it and each iterator see only the some cached values.
|
void |
run()
Iterates over the given source without using its returned value.
|
<U> Ix<U> |
scan(rx.functions.Func2<? super U,? super T,? extends U> aggregator)
Generates an iterable which acts like a running sum when iterating over the source iterable, e.g.,
For each element in T, it computes a value by using the current aggregation value and returns it.
|
<U> Ix<U> |
scan(U seed,
rx.functions.Func2<? super U,? super T,? extends U> aggregator)
Generates an iterable which acts like a running sum when iterating over the source iterable, e.g.,
For each element in T, it computes a value by using the current aggregation value and returns it.
|
Ix<T> |
share()
Returns an iterable which ensures the source iterable is
only traversed once and clients may take values from each other,
e.g., they share the same iterator.
|
Ix<T> |
skip(int num)
Skips the specified amount of items at the beginning of the source sequence.
|
Ix<T> |
skipLast(int num)
Returns an iterable which skips the last
num elements from the
source iterable. |
Ix<T> |
startWith(T value)
Returns an iterable which prefixes the source iterable values
by a constant.
|
Ix<Pair<T,T>> |
subsequent()
Returns each pair of subsequent elements as pairs.
|
Ix<Ix<T>> |
subsequent(int count)
Returns each pair of subsequent elements as pairs.
|
Ix<java.math.BigDecimal> |
sumBigDecimal()
Computes and signals the sum of the values of the BigDecimal source.
|
Ix<java.math.BigInteger> |
sumBigInteger()
Computes and signals the sum of the values of the BigInteger source.
|
Ix<java.lang.Double> |
sumDouble()
Computes and signals the sum of the values of the Double source.
|
Ix<java.lang.Float> |
sumFloat()
Computes and signals the sum of the values of the Float source.
|
Ix<java.lang.Integer> |
sumInt()
Computes and signals the sum of the values of the Integer source.
|
Ix<java.lang.Double> |
sumIntAsDouble()
Computes and signals the sum of the values of the Integer source by using
a double intermediate representation.
|
Ix<java.lang.Long> |
sumLong()
Computes and signals the sum of the values of the Long source.
|
Ix<java.lang.Double> |
sumLongAsDouble()
Computes and signals the sum of the values of the Long sourceby using
a double intermediate representation.
|
Ix<T> |
take(int num)
Returns the iterable which returns the first
num element. |
Ix<T> |
takeLast(int num)
Returns an iterable which takes only the last
num elements from the
source iterable. |
java.lang.Object[] |
toArray()
Returns an object array of all elements in this
iterable.
|
T[] |
toArray(T[] a)
Returns all elements from this iterable into either
the given array or a new array if the size requires.
|
static <T> rx.functions.Func1<java.lang.Iterable<T>,Ix<T>> |
toBuilder() |
<K> java.util.Map<K,T> |
toHashMap(rx.functions.Func1<? super T,? extends K> keySelector)
Convinience method to create a hashmap from the elements.
|
<K> java.util.Map<K,java.util.List<T>> |
toHashMultimap(rx.functions.Func1<? super T,? extends K> keySelector)
Convinience method to create a hash-multimap with list from the elements.
|
java.util.List<T> |
toList()
Iterates over and returns all elements in a list.
|
<K> java.util.Map<K,T> |
toMap(rx.functions.Func1<? super T,? extends K> keySelector,
rx.functions.Func0<? extends java.util.Map<K,T>> mapProvider)
Convert the iterable values into a map representation.
|
<K,V> java.util.Map<K,V> |
toMap(rx.functions.Func1<? super T,? extends K> keySelector,
rx.functions.Func1<? super T,? extends V> valueSelector,
rx.functions.Func0<? extends java.util.Map<K,V>> mapProvider)
Convert the iterable values into a map representation.
|
<K,V,C extends java.util.Collection<V>> |
toMultimap(rx.functions.Func1<? super T,? extends K> keySelector,
rx.functions.Func1<? super T,? extends V> valueSelector,
rx.functions.Func0<? extends java.util.Map<K,C>> mapProvider,
rx.functions.Func0<? extends C> collectionProvider)
Convert the values into a multimap representation where each
key can have multiple values.
|
rx.Observable<T> |
toObservable()
Converts this iterable into an observable builder
which uses the default scheduler of
Observable to emit values. |
rx.Observable<T> |
toObservable(rx.Scheduler scheduler)
Converts this iterable into an observable builder
which uses the supplied Scheduler to emit values.
|
<U,V> Ix<V> |
zipWith(java.lang.Iterable<? extends U> right,
rx.functions.Func2<? super T,? super U,? extends V> combiner)
Pairs each element from this and the oher iterable source and
combines them into a new value by using the
combiner
function. |
protected final java.lang.Iterable<T> it
protected Ix(java.lang.Iterable<T> source)
source
- the backing iterablepublic static <T> Ix<T> concat(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> sources)
T
- the value typesources
- the source iterablespublic static <T> Ix<T> concat(java.lang.Iterable<? extends T>... sources)
T
- the value typesources
- the sources to concatenatepublic static <T> Ix<T> defer(rx.functions.Func0<? extends java.lang.Iterable<T>> func)
func
for the actual source.T
- the element typefunc
- the function that returns an iterable.public static <T> Ix<T> from(java.lang.Iterable<T> source)
T
- the element typesource
- the source sequencepublic static <T> Ix<T> from(rx.Observable<T> source)
The resulting iterable does not support the remove()
method.
T
- the element typesource
- the source observablepublic static <T> Ix<T> from(T... ts)
T
- the element typets
- the array of tspublic static <T> Ix<T> just(T value)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
T
- the element typevalue
- the value to returnpublic static <T> Ix<T> error(java.lang.Throwable t)
Throwable
exception when the client invokes
next()
the first time. Any subsequent
next()
call will simply throw a NoSuchElementException
.
Calling remove()
will always throw a IllegalStateException
.
If the given Throwable instance extends a RuntimeException
, it is throws
as is, but when the throwable is a checked exception, it is wrapped
into a RuntimeException
.T
- the element type, irrelevantt
- the exception to throwpublic static <T> Ix<T> empty()
hasNext()
returns always false,
next()
throws a NoSuchElementException
and remove()
throws an IllegalStateException
.
Note that the Collections.emptyIterable()
static method is introduced by Java 7.T
- the element type, irrelevantpublic static <T> Ix<T> fromPart(int from, int to, T... ts)
T
- the element typefrom
- the source index inclusiveto
- the destination index exclusivets
- the array of tspublic static <T> Ix<T> generate(T seed, rx.functions.Func1<? super T,java.lang.Boolean> predicate, rx.functions.Func1<? super T,? extends T> next)
T value = seed;
while (predicate(value)) {
yield value;
value = next(value);
}
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
T
- the element typeseed
- the initial valuepredicate
- the predicate to terminate the processnext
- the function that computes the next value.public static <T> Ix<T> newBuilder(java.lang.Iterable<T> source)
T
- the element typesource
- the source sequencepublic static Ix<java.lang.Integer> range(int start, int count)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
start
- the starting value.count
- the number of elements to return, negative count means counting down from the start.public static Ix<java.lang.Long> range(long start, long count)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
start
- the starting value.count
- the number of elements to return, negative count means counting down from the start.public static <T> Ix<T> repeat(T t)
The resulting iterable does not support the remove()
method.
T
- the element typet
- the value to repeatpublic static <T> Ix<T> repeat(T t, int count)
The returned iterable does not support the remove()
method.
T
- the value typet
- the value to repeatcount
- the repeat amountpublic static <T> rx.functions.Func1<java.lang.Iterable<T>,Ix<T>> toBuilder()
T
- the element typepublic final <U,V> Ix<V> aggregate(rx.functions.Func2<? super U,? super T,? extends U> sum, rx.functions.Func2<? super U,? super java.lang.Integer,? extends V> divide)
sum
function parameter. Once the source is depleted, it
applies the divide
function and returns its result.
This operator is a general base for averaging (where sum(u, t) => u + t
, divide(u, index) => u / index
),
summing (where sum(u, t) => u + t
, and divide(u, index) => u)
),
minimum, maximum, etc.
If the traversal of the source fails due an exception, that exception is reflected on the
next()
call of the returned iterator.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.U
- the itermediate aggregation typeV
- the resulting aggregation typesum
- the function which takes the current itermediate value,
the current source value and should produce a new intermediate value.
for the first element of T, the U parameter will receive nulldivide
- the function which takes the last intermediate value and a total count of Ts seen and should return the final aggregation value.public final Ix<java.lang.Boolean> all(rx.functions.Func1<? super T,java.lang.Boolean> predicate)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
predicate
- the predicatepublic final Ix<java.lang.Boolean> any()
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final Ix<java.lang.Boolean> any(rx.functions.Func1<? super T,java.lang.Boolean> predicate)
predicate
- the predicate tester functionpublic final <V extends java.lang.Comparable<? super V>> Pair<T,V> argAndMax(rx.functions.Func1<? super T,? extends V> valueSelector)
V
- the value type for the comparison, must be self comparablevalueSelector
- the value selector functionpublic final <V> Pair<T,V> argAndMax(rx.functions.Func1<? super T,? extends V> valueSelector, java.util.Comparator<? super V> valueComparator)
V
- the value typevalueSelector
- the selector to extract the value from TvalueComparator
- the comparator to compare two valuespublic final <V extends java.lang.Comparable<? super V>> Pair<T,V> argAndMin(rx.functions.Func1<? super T,? extends V> valueSelector)
V
- the value type for the comparison, must be self comparablevalueSelector
- the value selector functionpublic final <V> Pair<T,V> argAndMin(rx.functions.Func1<? super T,? extends V> valueSelector, java.util.Comparator<? super V> valueComparator)
V
- the value typevalueSelector
- the selector to extract the value from TvalueComparator
- the comparator to compare two valuespublic final Ix<java.math.BigDecimal> averageBigDecimal()
Note that it uses forced cast of this sequence. If T != BigDecimal this method is guaranteed to throw ClassCastException.
public final Ix<java.math.BigDecimal> averageBigInteger()
Note that it uses forced cast of this sequence. If T != BigInteger this method is guaranteed to throw ClassCastException.
public final Ix<java.lang.Double> averageDouble()
public final Ix<java.lang.Float> averageFloat()
public final Ix<java.lang.Double> averageInt()
public final Ix<java.lang.Double> averageLong()
public final Ix<java.util.List<T>> buffer(int bufferSize)
bufferSize
lists.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
bufferSize
- the buffer size.public final <C> Ix<C> collect(rx.functions.Func0<C> collectionSupplier, rx.functions.Action2<C,? super T> collector)
collectionSupplier
- the function that creates a collection for individual iterationscollector
- the action that is called by the collection instance and the current
element in the sequencepublic final Ix<T> concatWith(java.lang.Iterable<? extends T> other)
iterator()
only happens when there is no more element in the first iterator.
The returned iterator forwards all remove()
calls
to the current source (first or next).
other
- the second iterablepublic final Ix<T> concatWith(T... values)
values
- the array valuespublic final Ix<T> concatWithAll(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> others)
others
- the other iterablespublic final Ix<java.lang.Boolean> contains(java.lang.Object value)
equals()
. The iterable then returns a single true or false.value
- the value to checkpublic final Ix<java.lang.Integer> count()
int
.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final Ix<java.lang.Long> countLong()
long
.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final Ix<T> dematerialize()
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final Ix<T> distinct()
equals()
public final <U> Ix<T> distinct(rx.functions.Func1<? super T,? extends U> keySelector)
equals()
U
- the key element typekeySelector
- the key selector for only-once filteringpublic final Ix<T> distinctNext()
public final <U> Ix<T> distinctNext(rx.functions.Func1<T,U> keySelector)
U
- the key typekeySelector
- the function to extract the keys which will be comparedpublic final Ix<T> doOnCompleted(rx.functions.Action0 action)
The returned iterator forwards all remove()
calls
to the source.
action
- the action to invokepublic final Ix<T> doOnNext(rx.functions.Action1<? super T> action)
The returned iterator forwards all remove()
calls
to the source.
action
- the action to invoke before each next() is returned.public final Ix<T> doWhile(rx.functions.Func0<java.lang.Boolean> gate)
source
as long as the gate is true. The gate function is checked only
when a pass over the source stream was completed.
Note that using this operator on an empty iterable may result
in a direct infinite loop in hasNext() or next() calls depending on the gate function.
The returned iterator forwards all remove()
calls
to the source.
gate
- the gate function to stop the repeatpublic final Ix<T> endWith(T value)
The returned iterable forwards all remove()
methods to the source iterable, except the last element where it
throws UnsupportedOperationException.
value
- the value to appendpublic final Ix<T> filter(rx.functions.Func1<? super T,java.lang.Boolean> predicate)
The returned iterator forwards all remove()
calls
to the source.
predicate
- the predicate functionpublic final Ix<T> filterIndexed(rx.functions.Func2<java.lang.Integer,? super T,java.lang.Boolean> predicate)
predicate
- the predicatepublic final T first()
public final T firstOrDefault(T defaultValue)
defaultValue
- the default value to returnpublic final <U> Ix<U> flatMap(rx.functions.Func1<? super T,? extends java.lang.Iterable<? extends U>> selector)
The returned iterator forwards all remove()
calls
to the current source (which might not accept it).
U
- the output element typeselector
- the selector for multiple Us for each Tpublic final void forEach(rx.functions.Action1<? super T> action)
action
- the action to invoke on with elementpublic final <K> Ix<GroupedIterable<K,T>> groupBy(rx.functions.Func1<? super T,? extends K> keySelector)
equals()
equality.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
K
- the result group element typekeySelector
- the key selectorpublic final <K,V> Ix<GroupedIterable<K,V>> groupBy(rx.functions.Func1<? super T,? extends K> keySelector, rx.functions.Func1<? super T,? extends V> valueSelector)
equals()
equality.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
K
- the result group element typeV
- the result group keyskeySelector
- the key selectorvalueSelector
- the value selectorpublic final <U extends java.util.Collection<? super T>> U into(U out)
U
- a collection typeout
- the output collectionpublic final Ix<java.lang.Boolean> isEmpty()
public final java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public final Ix<java.lang.String> join(java.lang.String separator)
The returned iterator forwards all remove()
calls
to the source.
separator
- the separator to usepublic final T last()
NoSuchElementException
if the iterable is empty.public final T lastOrDefault(T defaultValue)
defaultValue
- the default value to return if this sequence is emptypublic final <U> Ix<U> map(rx.functions.Func1<? super T,? extends U> selector)
U
- the output element typeselector
- the selector functionpublic final <U> Ix<U> mapIndexed(rx.functions.Func2<java.lang.Integer,? super T,? extends U> selector)
The returned iterator forwards all remove()
calls
to the source.
U
- the output element typeselector
- the selector functionpublic final Ix<rx.Notification<T>> materialize()
UnsupportedOperationException
for its remove()
method.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final <U extends java.lang.Comparable<? super U>> Ix<U> max()
U
- the self comparable typepublic final Ix<T> max(java.util.Comparator<? super T> comparator)
comparator
- the comparator to usepublic final <U extends java.lang.Comparable<? super U>> Ix<java.util.List<U>> maxBy()
U
- the source element type, which must be self comparablepublic final Ix<java.util.List<T>> maxBy(java.util.Comparator<? super T> comparator)
comparator
- the key comparatorpublic final <U extends java.lang.Comparable<? super U>> Ix<java.util.List<T>> mayBy(rx.functions.Func1<? super T,U> keySelector)
U
- the key type, which must be self-comparablekeySelector
- the selector for keyspublic final <U> Ix<java.util.List<T>> mayBy(rx.functions.Func1<? super T,U> keySelector, java.util.Comparator<? super U> keyComparator)
U
- the key typekeySelector
- the selector for keyskeyComparator
- the key comparatorpublic final Ix<T> memoize(int bufferSize)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
bufferSize
- the size of the bufferingpublic final Ix<T> memoizeAll()
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final <U extends java.lang.Comparable<? super U>> Ix<U> min()
U
- the self comparable typepublic final Ix<T> min(java.util.Comparator<? super T> comparator)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
comparator
- the comparator to usepublic final Ix<java.util.List<T>> minBy(java.util.Comparator<? super T> comparator)
comparator
- the key comparatorpublic final <U extends java.lang.Comparable<? super U>> Ix<java.util.List<T>> minBy(rx.functions.Func1<? super T,U> keySelector)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the key type, which must be self-comparablekeySelector
- the selector for keyspublic final <U> Ix<java.util.List<T>> minBy(rx.functions.Func1<? super T,U> keySelector, java.util.Comparator<? super U> keyComparator)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the key typekeySelector
- the selector for keyskeyComparator
- the key comparatorpublic final <U extends java.lang.Comparable<? super U>> Ix<java.util.List<U>> minxBy()
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the source element type, which must be self comparablepublic final <U> Ix<U> ofType(java.lang.Class<U> token)
next()
will throw a ClassCastException
.
The returned iterator forwards all remove()
calls
to the source.
U
- the result element typetoken
- the type tokenpublic final <U extends java.lang.Comparable<? super U>> Ix<U> orderBy()
Note: the element type should be self comparable or a ClassCastException is thrown.
U
- the source element type, which must be self comparablepublic final Ix<T> orderBy(java.util.Comparator<? super T> comparator)
comparator
- the value comparatorpublic final <U extends java.lang.Comparable<? super U>> Ix<T> orderBy(rx.functions.Func1<? super T,? extends U> keySelector)
U
- the key type for the ordering, must be self comparablekeySelector
- the key selector for comparisonpublic final <U> Ix<T> orderBy(rx.functions.Func1<? super T,? extends U> keySelector, java.util.Comparator<? super U> keyComparator)
U
- the key type for the orderingkeySelector
- the key selector for comparisonkeyComparator
- the key comparator functionpublic final void print()
Is the same as using this.run(Interactive.print())
.
public final void println()
Is the same as using this.run(Interactive.println())
.
public final <U> Ix<U> prune(rx.functions.Func1<? super java.lang.Iterable<? extends T>,? extends java.lang.Iterable<U>> func)
func
function for a shared instance of the source,
e.g., func.invoke(share(source))
.U
- the return typesfunc
- invoke the function on the buffering iterable and return an iterator over it.public final <U> Ix<U> publish(rx.functions.Func1<? super java.lang.Iterable<? super T>,? extends java.lang.Iterable<? extends U>> func, U initial)
The returned iterator will throw an UnsupportedOperationException
for remove()
method of its first element, then it might throw for any
subsequent element, depending on the source iterable.
U
- the return typesfunc
- invoke the function on the buffering iterable and return an iterator over it.initial
- the initial value to append to the output streampublic final <U> Ix<U> publish(rx.functions.Func1<? super java.lang.Iterable<T>,? extends java.lang.Iterable<U>> func)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the return typesfunc
- invoke the function on the buffering iterable and return an iterator over it.public final Ix<T> reduce(rx.functions.Func2<T,T,T> reducer)
reducer
- the reducer function that receives the first item or
the result of the previous application of the function as the first parameter
and the current item as the second parameter.public final void removeAll()
public final <U> Ix<U> replay(rx.functions.Func1<? super java.lang.Iterable<T>,? extends java.lang.Iterable<U>> func)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the return typesfunc
- invoke the function on the buffering iterable and return an iterator over it.public final <U> Ix<U> replay(rx.functions.Func1<? super java.lang.Iterable<T>,? extends java.lang.Iterable<U>> func, int bufferSize)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the return typesfunc
- invoke the function on the buffering iterable and return an iterator over it.bufferSize
- the buffer sizepublic final void run()
public final <U> Ix<U> scan(rx.functions.Func2<? super U,? super T,? extends U> aggregator)
U
- the destination element typeaggregator
- the function which takes the current running aggregation value, the current element and produces a new aggregation value.public final <U> Ix<U> scan(U seed, rx.functions.Func2<? super U,? super T,? extends U> aggregator)
The returned iterator forwards all remove()
calls
to the source.
U
- the destination element typeseed
- the initial value of the running aggregationaggregator
- the function which takes the current running aggregation value, the current element and produces a new aggregation value.public final Ix<T> share()
public final Ix<T> skip(int num)
num
- the number of elements to skippublic final Ix<T> skipLast(int num)
num
elements from the
source iterable.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
num
- the number of elements to skip at the endpublic final Ix<T> startWith(T value)
concat(singleton(value), source)
.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method for the first element, and might
throw for subsequent elements, depending on the source iterable.
value
- the value to prefixpublic final Ix<Pair<T,T>> subsequent()
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
public final Ix<Ix<T>> subsequent(int count)
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
count
- the number of subsequent elementspublic final Ix<java.math.BigDecimal> sumBigDecimal()
public final Ix<java.math.BigInteger> sumBigInteger()
public final Ix<java.lang.Double> sumDouble()
public final Ix<java.lang.Float> sumFloat()
public final Ix<java.lang.Integer> sumInt()
public final Ix<java.lang.Double> sumIntAsDouble()
public final Ix<java.lang.Long> sumLong()
public final Ix<java.lang.Double> sumLongAsDouble()
public final Ix<T> take(int num)
num
element.
from the source iterable.
The returned iterator forwards all remove()
calls
to the source.
num
- the number of items to takepublic final Ix<T> takeLast(int num)
num
elements from the
source iterable.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
num
- the number of elements to skip at the endpublic final java.lang.Object[] toArray()
public final T[] toArray(T[] a)
a
- the output arraypublic final <K> java.util.Map<K,T> toHashMap(rx.functions.Func1<? super T,? extends K> keySelector)
K
- the key typekeySelector
- the key selectorpublic final <K> java.util.Map<K,java.util.List<T>> toHashMultimap(rx.functions.Func1<? super T,? extends K> keySelector)
K
- the key typekeySelector
- the key selectorpublic final java.util.List<T> toList()
public final <K> java.util.Map<K,T> toMap(rx.functions.Func1<? super T,? extends K> keySelector, rx.functions.Func0<? extends java.util.Map<K,T>> mapProvider)
If an element maps to the same key, the existing value will be overwritten.
See Functions.hashMapProvider() and others for some standard map implementations.
K
- the key typekeySelector
- the function to extract a key from an elementmapProvider
- the map providerpublic final <K,V> java.util.Map<K,V> toMap(rx.functions.Func1<? super T,? extends K> keySelector, rx.functions.Func1<? super T,? extends V> valueSelector, rx.functions.Func0<? extends java.util.Map<K,V>> mapProvider)
If an element maps to the same key, the existing value will be overwritten.
K
- the key typeV
- the value typekeySelector
- the function to extract a key from an elementvalueSelector
- the function to extract a value from an elementmapProvider
- the map providerpublic final <K,V,C extends java.util.Collection<V>> java.util.Map<K,C> toMultimap(rx.functions.Func1<? super T,? extends K> keySelector, rx.functions.Func1<? super T,? extends V> valueSelector, rx.functions.Func0<? extends java.util.Map<K,C>> mapProvider, rx.functions.Func0<? extends C> collectionProvider)
See Functions.hashMapProvider(), Functions.arrayListProvider() and others for some standard map implementations.
K
- the key typeV
- the value typeC
- the collection typekeySelector
- the key selectorvalueSelector
- the value selectormapProvider
- the provider for the base mapcollectionProvider
- the provider for the value collectionpublic final rx.Observable<T> toObservable()
Observable
to emit values.public final rx.Observable<T> toObservable(rx.Scheduler scheduler)
scheduler
- the schedulerpublic final <U,V> Ix<V> zipWith(java.lang.Iterable<? extends U> right, rx.functions.Func2<? super T,? super U,? extends V> combiner)
combiner
function.
The returned iterator will throw an UnsupportedOperationException
for its remove()
method.
U
- the right source typeV
- the result typeright
- the right sourcecombiner
- the combiner function