public interface UnmodIterable<T> extends Iterable<T>, Transformable<T>
| Modifier and Type | Interface and Description |
|---|---|
static class |
UnmodIterable.AbstractUnmodIterable<T>
Implements equals and hashCode() methods compatible with all java.util collections (this
algorithm is not order-dependent) and toString which takes the name of the sub-class.
|
| Modifier and Type | Method and Description |
|---|---|
default UnmodIterable<T> |
concat(Iterable<? extends T> list)
Add items to the end of this Transformable (precat() adds to the beginning)
|
default UnmodIterable<T> |
drop(long n)
Ignore the first n items and return only those that come after.
|
default UnmodIterable<T> |
filter(Function1<? super T,Boolean> f)
Return only the items for which the given predicate returns true.
|
default <B> UnmodIterable<B> |
flatMap(Function1<? super T,Iterable<B>> f)
Transform each item into zero or more new items using the given function.
|
default <B> B |
foldLeft(B ident,
Function2<B,? super T,B> reducer)
Apply the function to each item, accumulating the result in u.
|
default <B> B |
foldLeft(B ident,
Function2<B,? super T,B> reducer,
Function1<? super B,Boolean> terminateWhen)
Normally you want to terminate by doing a take(), drop(), or takeWhile() before you get to the
fold, but if you need to terminate based on the complete result so far, you can provide your
own termination condition to this version of foldLeft().
|
static int |
hash(Iterable is)
This is correct, but O(n).
|
static int |
hashCode(Iterable is)
Deprecated.
|
default Option<T> |
head()
The first item in this sequence.
|
UnmodIterator<T> |
iterator()
A one-time use, mutable, not-thread-safe way to get each value of the underling collection in
turn.
|
default <B> UnmodIterable<B> |
map(Function1<? super T,? extends B> f)
Transform each item into exactly one new item using the given function.
|
default UnmodIterable<T> |
precat(Iterable<? extends T> list)
Add items to the beginning of this Transformable ("precat" is a PREpending version of conCAT).
|
default UnmodIterable<T> |
take(long numItems)
Return only the first n items.
|
default UnmodIterable<T> |
takeWhile(Function1<? super T,Boolean> f)
Return items from the beginning until the given predicate returns false.
|
static String |
toString(String name,
Iterable iterable)
Computes a reasonable to-string.
|
forEach, spliteratortoImList, toImMap, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableSet, toMutableSortedMap, toMutableSortedSet@Deprecated static int hashCode(Iterable is)
hash(Iterable) to avoid confusion with instance method
Object.hashCode() 2016-09-17static int hash(Iterable is)
UnmodIterator<T> iterator()
default UnmodIterable<T> concat(Iterable<? extends T> list)
concat in interface Transformable<T>list - the items to adddefault UnmodIterable<T> precat(Iterable<? extends T> list)
precat in interface Transformable<T>list - the items to adddefault UnmodIterable<T> drop(long n)
drop in interface Transformable<T>n - the number of items at the beginning of this Transformable to ignoredefault <B> B foldLeft(B ident,
Function2<B,? super T,B> reducer)
foldLeft in interface Transformable<T>ident - the accumulator and starting value. This will be passed to the function on the
first iteration to be combined with the first member of the underlying data source. For some
operations you'll need to pass an identity, e.g. for a sum, pass 0, for a product, pass 1 as
this parameter.reducer - combines each value in the list with the result so far. The initial result is u.default <B> B foldLeft(B ident,
Function2<B,? super T,B> reducer,
Function1<? super B,Boolean> terminateWhen)
foldLeft in interface Transformable<T>ident - the accumulator and starting value. This will be passed to the function on the
first iteration to be combined with the first member of the underlying data source. For some
operations you'll need to pass an identity, e.g. for a sum, pass 0, for a product, pass 1 as
this parameter.reducer - combines each value in the list with the result so far. The initial result is u.terminateWhen - returns true when the termination condition is reached and will stop
processing the input at that time, returning the latest u.default UnmodIterable<T> filter(Function1<? super T,Boolean> f)
filter in interface Transformable<T>f - a function that returns true for items to keep, false for items to dropdefault <B> UnmodIterable<B> flatMap(Function1<? super T,Iterable<B>> f)
flatMap in interface Transformable<T>f - yields a Transformable of 0 or more results for each input item.default <B> UnmodIterable<B> map(Function1<? super T,? extends B> f)
map in interface Transformable<T>f - a function that returns a new value for any value in the inputdefault UnmodIterable<T> take(long numItems)
take in interface Transformable<T>numItems - the maximum number of items in the returned view.default UnmodIterable<T> takeWhile(Function1<? super T,Boolean> f)
takeWhile in interface Transformable<T>f - the predicate (test function)Copyright © 2017. All rights reserved.