public class MetricTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.util.Collection<?> |
createHashSet(boolean multi)
Creates a new empty set or multiset.
|
static java.util.Collection<?> |
createHashSet(boolean multi,
java.util.Collection<?> contents)
Creates a new set or multiset with initial contents.
|
static int |
elementCount(java.util.Collection<?> c,
java.lang.Object element)
Counts the number of occurrences of an element in a set or multiset.
|
static <T> java.util.Iterator<T> |
getFlatIterator(java.util.Collection<T> c)
Obtains an iterator over the unique elements of a set or multiset.
|
static java.lang.Number |
getNumber(float f)
Optimizes a float return value for a metric.
|
static boolean |
isEmptyElement(java.lang.Object o)
Checks if an object represents an empty model element reference.
|
static boolean |
isMultiSet(java.util.Collection<?> c)
Tests if a collection is a multiset.
|
static void |
removeAny(java.util.Collection<?> c,
java.lang.Object element)
Removes all occurrences of an element in a set or multiset.
|
public static java.util.Collection<?> createHashSet(boolean multi)
multi
- true
to create a multiset, false
to create a regular set.HashMultiSet
public static java.util.Collection<?> createHashSet(boolean multi, java.util.Collection<?> contents)
multi
- true
to create a multiset, false
to create a regular set.contents
- Initial contents of the (multi) set.HashMultiSet
with initial contents.public static boolean isMultiSet(java.util.Collection<?> c)
c
- Collection to test.true
if c is an instance of HashMultiSet
.public static int elementCount(java.util.Collection<?> c, java.lang.Object element)
c
- The set or multiset. This must be an instance of java.util.Set
or HashMultiSet
.element
- The element to count.public static void removeAny(java.util.Collection<?> c, java.lang.Object element)
c
- The set or multiset. This must be an instance of java.util.Set
or HashMultiSet
.element
- The element to remove.public static <T> java.util.Iterator<T> getFlatIterator(java.util.Collection<T> c)
T
- Type of the elements in the setc
- The set or multiset.public static java.lang.Number getNumber(float f)
If the value has no fractional part and less than 6 significant digits, its value is wrapped in an Integer.
f
- The return value of the metricpublic static boolean isEmptyElement(java.lang.Object o)
o
- Object to testtrue
if o
is an empty String