public class Operations extends Object
| Modifier and Type | Class and Description |
|---|---|
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>> inputs)
Concatenates several
Iterables into one |
static <T> Iterable<T> |
concat(Iterable<? extends T>... inputs) |
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> Iterable<T> |
filter(Iterable<? extends T> input,
Condition<? super T> condition) |
static <T,S> Iterable<T> |
filter(Iterable<S> input,
Class<T> type) |
static <T> Set<T> |
filter(Set<? extends T> input,
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 <T> Comparator<? super Iterable<T>> |
lexicalOrder(Comparator<? super T> elementComparator) |
static <I,O> Collection<O> |
map(Collection<I> input,
Operations.Transformation<? super I,O> transformation) |
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> Iterator<O> |
map(Iterator<I> input,
Operations.Transformation<? super I,O> transformation) |
static <I,O> Set<O> |
map(Set<? extends I> input,
Operations.FunctorEx<I,O> functor)
A simple second-order map function for
Sets |
static <I,O> Iterable<O> |
mapConcat(Iterable<I> input,
Operations.Transformation<? super I,Iterable<O>> transformation) |
static <I,O> Iterator<O> |
mapConcat(Iterator<I> input,
Operations.Transformation<? super I,Iterable<O>> transformation) |
static <T> Iterable<T> |
singleton(T element) |
static <T> Iterator<T> |
singletonIterator(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. |
static <T> Iterator<T> |
synchronize(Iterator<?> first,
Iterator<? extends T> second) |
static <T> String |
toString(Iterable<T> iterable) |
public static final Multimap<?,?> EMPTY_MULTIMAP
public static <S,T> Multimap<S,T> emptyMultimap()
@SafeVarargs public static <T> Iterable<T> concat(Iterable<? extends T>... inputs)
public static <T> Iterator<T> singletonIterator(T element)
public static <T> Iterable<T> singleton(T element)
public static <T> Iterable<T> concat(Iterable<? extends Iterable<? extends T>> inputs)
Iterables into onepublic static <T> Iterator<T> synchronize(Iterator<?> first, Iterator<? extends T> second)
T - the type of elements of iteratorsfirst - the elements that should come firstsecond - the elements that should come nextpublic static <T> Iterable<ArrayList<T>> split(Iterable<? extends T> elements, int batchSize)
Iterable on batches with at most given number of
elements.T - the type of elements in the Iterableelements - 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.T - the type of elements in the Collectionelements - 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<? extends T> input, Condition<? super T> condition)
T - the type of elementsinput - the input iterator over these elementscondition - the condition used for filteringpublic static <T> Set<T> filter(Set<? extends T> input, Condition<? super T> condition, int size)
T - the type of elementsinput - 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
outputI - the type of input of elementsO - the type of output elementsinput - the input elementstransformation - the transformation for elementspublic static <I,O> Iterable<O> mapConcat(Iterable<I> input, Operations.Transformation<? super I,Iterable<O>> transformation)
public static <I,O> Collection<O> map(Collection<I> input, Operations.Transformation<? super I,O> transformation)
public static <I,O> Iterator<O> map(Iterator<I> input, Operations.Transformation<? super I,O> transformation)
public static <I,O> Iterator<O> mapConcat(Iterator<I> input, Operations.Transformation<? super I,Iterable<O>> transformation)
public 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.K - the type of the keys of the MultimapV - the type of the values of the Multimapfirst - the entries that should be printedsecond - the entries that should be skippedwriter - the writer using which the entries should be printedprefix - the string to be appended to every lineIOException - if any I/O error occurspublic 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.T - the type of elementsfirst - the elements to be printedsecond - the elements to be skippedwriter - the writer using which the elements should be printedprefix - the string to be appended to every lineIOException - if any I/O error occurspublic static <I,O> Set<O> map(Set<? extends I> input, Operations.FunctorEx<I,O> functor)
SetsI - the type of elements of the input SetO - the type of elements of this Setinput - the input Set to be convertedfunctor - the Operations.Functor that applies to the input elementsOperations.Functor to the
elements in the input Setpublic static final <T> Comparator<? super Iterable<T>> lexicalOrder(Comparator<? super T> elementComparator)
T - the type of elementselementComparator - a Comparator on these elementsComparator that compares Iterable according to
lexical order w.r.t. element ordering defined by the provided
element Comparator.Copyright © 2011–2024 Live Ontologies Project. All rights reserved.