public class Operations extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Operations.Condition<T>
Boolean conditions over some type.
|
static interface |
Operations.Functor<I,O>
A simple object that transforms objects of type I to objects of type O
|
static interface |
Operations.FunctorEx<I,O>
An extension of
Operations.Functor which can do the reverse transformation |
static interface |
Operations.Transformation<I,O>
Transformations of input values to output values
|
| Modifier and Type | Field and Description |
|---|---|
static Multimap<?,?> |
EMPTY_MULTIMAP |
| Constructor and Description |
|---|
Operations() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Iterable<T> |
concat(Iterable<? extends Iterable<? extends T>> input)
Concatenates several
Iterables into one |
static <T> Iterable<T> |
concat(Iterable<? extends T> a,
Iterable<? extends T> b) |
static <T> void |
dumpDiff(Collection<T> first,
Collection<T> second,
Writer writer,
String prefix)
Prints the elements present in the first
Collection but not in
the second Collection using the given Writer and
prefixing all messages with a given prefix. |
static <K,V> void |
dumpDiff(Multimap<K,V> first,
Multimap<K,V> second,
Writer writer,
String prefix)
|
static <S,T> Multimap<S,T> |
emptyMultimap() |
static <T,S> Iterable<T> |
filter(Iterable<S> input,
Class<T> type) |
static <T> Iterable<T> |
filter(Iterable<T> input,
Operations.Condition<? super T> condition) |
static <T> Set<T> |
filter(Set<T> input,
Operations.Condition<? super T> condition,
int size)
Returns read-only view of the given set consisting of the elements
satisfying a given condition, if the number of such elements is known
|
static <T> Collection<T> |
getCollection(Iterable<T> iterable,
int size) |
static <I,O> Iterable<O> |
map(Iterable<I> input,
Operations.Transformation<? super I,O> transformation)
Transforms elements using a given
Operations.Transformation the output
elements consist of the result of the transformation in the same order;
if the transformation returns null, it is not included in the
output |
static <I,O> Set<O> |
map(Set<? extends I> input,
Operations.FunctorEx<I,O> functor)
A simple second-order map function
|
static <T> Iterable<T> |
singleton(T element) |
static <T> Collection<ArrayList<T>> |
split(Collection<? extends T> elements,
int batchSize)
Splits the input
Collection on batches with at most given number
of elements. |
static <T> Iterable<ArrayList<T>> |
split(Iterable<? extends T> elements,
int batchSize)
Splits the input
Iterable on batches with at most given number of
elements. |
public static final Multimap<?,?> EMPTY_MULTIMAP
public static <S,T> Multimap<S,T> emptyMultimap()
public static <T> Iterable<T> singleton(T element)
public static <T> Iterable<T> concat(Iterable<? extends Iterable<? extends T>> input)
Iterables into onepublic static <T> Iterable<ArrayList<T>> split(Iterable<? extends T> elements, int batchSize)
Iterable on batches with at most given number of
elements.elements - the Iterable to be splitbatchSize - the maximal number of elements in batchesIterable of batches containing elements from the input
collectionconcat(Iterable)public static <T> Collection<ArrayList<T>> split(Collection<? extends T> elements, int batchSize)
Collection on batches with at most given number
of elements.elements - the Collection to be splitbatchSize - the maximal number of elements in batchesCollection of batches containing elements from the
input collectionpublic static <T> Collection<T> getCollection(Iterable<T> iterable, int size)
public static <T> Iterable<T> filter(Iterable<T> input, Operations.Condition<? super T> condition)
input - the input iteratorcondition - the condition used for filteringpublic static <T> Set<T> filter(Set<T> input, Operations.Condition<? super T> condition, int size)
input - the given set to be filteredcondition - the condition used for filtering the set. Must be consistent
with equals() for T, that is: a.equals(b) must imply that
holds(a) == holds(b)size - the number of elements in the filtered setpublic static <I,O> Iterable<O> map(Iterable<I> input, Operations.Transformation<? super I,O> transformation)
Operations.Transformation the output
elements consist of the result of the transformation in the same order;
if the transformation returns null, it is not included in the
outputinput - the input elementstransformation - the transformation for elementspublic static <K,V> void dumpDiff(Multimap<K,V> first, Multimap<K,V> second, Writer writer, String prefix) throws IOException
Multimap but not in
the second Multimap using the given Writer and prefixing
all messages with a given prefix.first - second - writer - prefix - IOExceptionpublic static <T> void dumpDiff(Collection<T> first, Collection<T> second, Writer writer, String prefix) throws IOException
Collection but not in
the second Collection using the given Writer and
prefixing all messages with a given prefix.first - second - writer - prefix - IOExceptionpublic static <I,O> Set<O> map(Set<? extends I> input, Operations.FunctorEx<I,O> functor)
input - functor - Copyright © 2011-2015 Department of Computer Science, University of Oxford. All Rights Reserved.