|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.semanticweb.elk.util.collections.Operations
public class Operations
Some useful static methods for collections
| Nested Class Summary | |
|---|---|
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 |
| Field Summary | |
|---|---|
static Multimap<?,?> |
EMPTY_MULTIMAP
|
| Constructor Summary | |
|---|---|
Operations()
|
|
| Method Summary | ||
|---|---|---|
static
|
concat(Iterable<? extends Iterable<? extends T>> input)
Concatenates several Iterables into one |
|
static
|
concat(Iterable<? extends T> a,
Iterable<? extends T> b)
|
|
static
|
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
|
dumpDiff(Multimap<K,V> first,
Multimap<K,V> second,
Writer writer,
String prefix)
Prints key-value entries present in the first Multimap but not in
the second Multimap using the given Writer and prefixing
all messages with a given prefix. |
|
static
|
emptyMultimap()
|
|
static
|
filter(Iterable<S> input,
Class<T> type)
|
|
static
|
filter(Iterable<T> input,
Operations.Condition<? super T> condition)
|
|
static
|
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
|
getCollection(Iterable<T> iterable,
int size)
|
|
static
|
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
|
map(Set<? extends I> input,
Operations.FunctorEx<I,O> functor)
A simple second-order map function |
|
static
|
singleton(T element)
|
|
static
|
split(Collection<? extends T> elements,
int batchSize)
Splits the input Collection on batches with at most given number
of elements. |
|
static
|
split(Iterable<? extends T> elements,
int batchSize)
Splits the input Iterable on batches with at most given number of
elements. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Multimap<?,?> EMPTY_MULTIMAP
| Constructor Detail |
|---|
public Operations()
| Method Detail |
|---|
public static <S,T> Multimap<S,T> emptyMultimap()
public static <T> Iterable<T> concat(Iterable<? extends T> a,
Iterable<? extends T> b)
public static <T> Iterable<T> singleton(T element)
public static <T> Iterable<T> concat(Iterable<? extends Iterable<? extends T>> input)
Iterables into one
input - the Iterable of Iterables to be concatenated
Iterable consisting of all elements found in input
Iterables
public 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 batches
Iterable 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 batches
Collection of batches containing elements from the
input collection
public 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 filtering
public static <T,S> Iterable<T> filter(Iterable<S> input,
Class<T> type)
public 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 set
public 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
output
input - the input elementstransformation - the transformation for elements
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.
first - second - writer - prefix -
IOException
public 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 -
IOException
public static <I,O> Set<O> map(Set<? extends I> input,
Operations.FunctorEx<I,O> functor)
input - functor -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||