public abstract class Xform<A> extends Object implements UnmodIterable<A>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
Xform.RunList
A RunList is a list of Operations "compiled" from an Xform.
|
| Modifier and Type | Method and Description |
|---|---|
Xform<A> |
concat(Iterable<? extends A> list)
Add items to the end of this Transformable (precat() adds to the beginning)
|
Xform<A> |
drop(long n)
The number of items to drop from the beginning of the output.
|
Xform<A> |
dropWhile(Fn1<? super A,Boolean> predicate)
The number of items to drop from the beginning of the output.
|
static <T> Xform<T> |
empty() |
Xform<A> |
filter(Fn1<? super A,Boolean> f)
Return only the items for which the given predicate returns true.
|
<B> Xform<B> |
flatMap(Fn1<? super A,Iterable<B>> f)
Transform each item into zero or more new items using the given function.
|
<B> B |
fold(B ident,
Fn2<? super B,? super A,B> reducer)
Provides a way to collect the results of the transformation.
|
<G,B> Or<G,B> |
foldUntil(G accum,
Fn2<? super G,? super A,B> terminator,
Fn2<? super G,? super A,G> reducer)
Thit implementation should be correct, but could be slow in the case where previous operations
are slow and the terminateWhen operation is fast and terminates early.
|
UnmodIterator<A> |
iterator()
A one-time use, mutable, not-thread-safe way to get each value of the underling collection in
turn.
|
<B> Xform<B> |
map(Fn1<? super A,? extends B> f)
Transform each item into exactly one new item using the given function.
|
static <T> Xform<T> |
of(Iterable<? extends T> list)
Static factory methods
|
Xform<A> |
precat(Iterable<? extends A> list)
Add items to the beginning of this Transformable ("precat" is a PREpending version of conCAT).
|
Xform<A> |
take(long numItems)
Return only the first n items.
|
Xform<A> |
takeWhile(Fn1<? super A,Boolean> f)
Return items from the beginning until the given predicate returns false.
|
protected abstract Xform.RunList |
toRunList() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithash, head, toStringforEach, spliteratortoImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableRrbt, toMutableSet, toMutableSortedMap, toMutableSortedSetpublic static final Xform EMPTY
public static <T> Xform<T> empty()
public UnmodIterator<A> iterator()
UnmodIterablepublic Xform<A> concat(Iterable<? extends A> list)
UnmodIterableconcat in interface UnmodIterable<A>concat in interface Transformable<A>list - the items to addpublic Xform<A> precat(Iterable<? extends A> list)
UnmodIterableprecat in interface UnmodIterable<A>precat in interface Transformable<A>list - the items to addpublic Xform<A> drop(long n)
drop in interface UnmodIterable<A>drop in interface Transformable<A>n - the number of items at the beginning of this Transformable to ignorepublic Xform<A> dropWhile(Fn1<? super A,Boolean> predicate)
dropWhile in interface UnmodIterable<A>dropWhile in interface Transformable<A>predicate - the predicate (test function)public <B> B fold(B ident,
Fn2<? super B,? super A,B> reducer)
fold in interface UnmodIterable<A>fold in interface Transformable<A>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.public <G,B> Or<G,B> foldUntil(G accum, Fn2<? super G,? super A,B> terminator, Fn2<? super G,? super A,G> reducer)
foldUntil in interface UnmodIterable<A>foldUntil in interface Transformable<A>accum - 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.terminator - return null to continue processing. Return non-null to terminate
the foldUntil and return Or.bad of this value. This function is called at the beginning
of each "loop", thus it's first called with the original value of accum and the first item
to process. Returning non-null immediately will prevent the reducer from ever being called.reducer - combines each value in the list with the result so far. The initial result is u.Or where the Or.good() is an eagerly evaluated result and
Or.bad() is whatever terminateWhen returned.public Xform<A> filter(Fn1<? super A,Boolean> f)
UnmodIterablefilter in interface UnmodIterable<A>filter in interface Transformable<A>f - a function that returns true for items to keep, false for items to droppublic <B> Xform<B> flatMap(Fn1<? super A,Iterable<B>> f)
UnmodIterableflatMap in interface UnmodIterable<A>flatMap in interface Transformable<A>f - yields a Transformable of 0 or more results for each input item.public <B> Xform<B> map(Fn1<? super A,? extends B> f)
UnmodIterablemap in interface UnmodIterable<A>map in interface Transformable<A>f - a function that returns a new value for any value in the inputprotected abstract Xform.RunList toRunList()
public Xform<A> take(long numItems)
UnmodIterabletake in interface UnmodIterable<A>take in interface Transformable<A>numItems - the maximum number of items in the returned view.public Xform<A> takeWhile(Fn1<? super A,Boolean> f)
UnmodIterabletakeWhile in interface UnmodIterable<A>takeWhile in interface Transformable<A>f - the predicate (test function)Copyright © 2019. All rights reserved.