|
jInfer | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcz.cuni.mff.ksi.jinfer.base.utils.BaseUtils
public final class BaseUtils
Various utility functions for jInfer. Library class.
| Nested Class Summary | |
|---|---|
static interface |
BaseUtils.Predicate<T>
Interface describing an object that decides whether the predicate (described by this object) applies to an argument or not. |
| Field Summary | |
|---|---|
static Comparator<AbstractNamedNode> |
NAMED_NODE_COMPARATOR
Comparator for AbstractNamedNodes, based on their
AbstractNamedNode.name. |
| Method Summary | ||
|---|---|---|
static
|
cloneList(List<T> l,
int n)
Creates a list containing the specified list N times in a row. |
|
static
|
equal(X arg1,
X arg2)
Checks whether two objects are equal in the following sense. |
|
static
|
filter(List<T> target,
BaseUtils.Predicate<T> predicate)
Filters the collection, leaving only elements where predicate applies. |
|
static
|
intersect(Set<T> set1,
Set<T> set2)
Calculates and returns the intersection of the two specified sets. |
|
static
|
isEmpty(Collection<T> c)
Checks whether the collection is empty, that means NULL or empty as in "no elements within". |
|
static boolean |
isEmpty(String s)
Checks whether the string is empty, that means NULL or equal to "". |
|
static
|
isSubset(Collection<T> l1,
Collection<T> l2)
Checks whether the first collection provided is a subset of the second collection provided. |
|
static
|
rndSubset(Collection<T> c,
double ratio)
Returns a random subset of the specified collection, so that its size is a specified ratio of the original collection size. |
|
static
|
rndSubset(Collection<T> c,
int count)
Returns a random subset of the specified collection of requested size. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Comparator<AbstractNamedNode> NAMED_NODE_COMPARATOR
AbstractNamedNodes, based on their
AbstractNamedNode.name.
Potential null values will be sorted last.
| Method Detail |
|---|
public static <T> List<T> filter(List<T> target,
BaseUtils.Predicate<T> predicate)
T - target - Collection to be filtered.predicate - Predicate determining whether to accept current element.
public static <T> boolean isEmpty(Collection<T> c)
T - c - Collection to check.
public static boolean isEmpty(String s)
s - String to check.
public static <T> List<T> cloneList(List<T> l,
int n)
l - List to be cloned. Must not be null.n - How many times should the list be cloned. Must be non-negative.
public static <T> Set<T> intersect(Set<T> set1,
Set<T> set2)
set1 - First set to interset, must not be null.set2 - Second set to interset, must not be null.
public static <T> List<T> rndSubset(Collection<T> c,
double ratio)
T - Type parameter.c - Collection to pick from.ratio - Requested ratio.
public static <T> List<T> rndSubset(Collection<T> c,
int count)
T - Type parameter.c - Collection to pick from.count - Requested size of the subset.
public static <T> boolean isSubset(Collection<T> l1,
Collection<T> l2)
T - Type of the collections.l1 - First collection.l2 - Second collection.
true if the first collection is a subset of the second
(every item of the first is contained in the second), false
otherwise.
public static <X> boolean equal(X arg1,
X arg2)
null, they are equal.null and the other is not, they are
not equal.null, their equality is decided by the
call to their usual Object.equals(Object).
X - Type of both objects to be checked.arg1 - First object to be checked.arg2 - Second object to be checked.
True if the specified objects are equal in the sense
described above, false otherwise.
|
jInfer | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||