|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.Sets
public class Sets
utility class for calculations on sets, lists and other collections.
| Method Summary | ||
|---|---|---|
static
|
aggregateBigDecimal(Map<T,BigDecimal> data,
PatternExtractor<? super T,P> pattern)
|
|
static
|
aggregatedDoubleValues(Map<T,N> data,
int maxEntries,
T remainingValueKey,
Comparator<Map.Entry<T,N>> comparator)
|
|
static
|
aggregateDouble(Map<T,? extends Number> data,
PatternExtractor<? super T,P> pattern)
|
|
static
|
asList(Collection<T> col)
convenience method to display a collection in a JList for example |
|
static
|
bottomDoubleValues(Map<T,N> data,
int maxEntries,
T remainingValueKey)
aggregates the given Map into one that only contains top values from the bottom. |
|
static
|
difference(Collection<? extends T> set1,
Collection<? extends T> set2)
returns a set that contains all elements from set1 that are not in set2 |
|
static
|
distinctValues(Collection<T> col,
PatternExtractor<? super T,P> extractor,
Filter<? super T> filter)
|
|
static
|
extract(Collection<T> col,
Filter<? super T> filter)
returns a new Collection that will only contain those elements that passed the filter; the given col remains untouched. |
|
static
|
filter(Collection<T> col,
Filter<? super T> filter)
filters all objects out of the given col that are not accepted by the filter; the dropout is returned as a separate Collection. |
|
static TreeMap<Date,BigDecimal> |
groupAndFill(Map<Date,? extends Number> data,
TimeInterval interval)
groups the numbers based on dates so that there is one date per given interval; in addition, all missing invervals within the range are filled with BigDecimal.ZERO. |
|
static
|
groupBy(Collection<T> col,
PatternExtractor<? super T,P> extractor,
Filter<? super T> filter)
splits the given collection into many, where the extractor is the discriminator |
|
static
|
indexOf(T obj,
Collection<T> col,
Discriminator<T> d)
|
|
static
|
keyForValue(Map<K,V> map,
V value)
|
|
static
|
keysForValue(Map<K,V> map,
V value)
|
|
static
|
makeSet(T[] array)
|
|
static
|
makeSet(T[] array,
boolean ignoreDuplicates)
|
|
static
|
map(Collection<T> col,
PatternExtractor<? super T,P> extractor,
Filter<? super T> filter)
if a single pattern is extracted more than once from the collection, simply the last occurrence is mapped to that pattern |
|
static
|
randomElement(Collection<T> col)
|
|
static
|
reverseMap(Map<K,V> map)
generates a reversed map, mapping values to keys |
|
static boolean |
same(Map<?,?> m1,
Map<?,?> m2)
|
|
static
|
sortByValues(Map<K,V> map)
returns a sorted map that is initialized with the given map and sorted by the values |
|
static
|
sortByValues(Map<K,V> map,
boolean ascending)
returns a sorted map that is initialized with the given map and sorted by the values |
|
static
|
sortByValues(Map<K,V> map,
Comparator<? super V> comparator)
returns a sorted map that is initialized with the given map and sorted by the values |
|
static
|
topBigDecimalValues(Map<T,? extends Number> data,
int maxEntries,
T remainderKey)
converts the given Map into one that only contains top values. |
|
static
|
topDoubleValues(Map<T,N> data,
int maxEntries,
T remainingValueKey)
aggregates the given Map into one that only contains top values. |
|
static String |
toString(Collection<?> col)
|
|
static String |
toString(Map<?,?> map)
|
|
static void |
verifyCollection(Collection<?> col,
Class<?> type)
verifies that every element of the given collection is indeed assignable from the given type |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String toString(Collection<?> col)
public static String toString(Map<?,?> map)
Strings.mapAsString(Map)public static <T> List<T> asList(Collection<T> col)
ArrayList.
public static <T> ArrayList<T> filter(Collection<T> col,
Filter<? super T> filter)
public static <P,T> HashMap<P,BigDecimal> aggregateBigDecimal(Map<T,BigDecimal> data,
PatternExtractor<? super T,P> pattern)
public static <P,T> HashMap<P,Double> aggregateDouble(Map<T,? extends Number> data,
PatternExtractor<? super T,P> pattern)
public static <T,N extends Number> HashMap<T,Double> topDoubleValues(Map<T,N> data,
int maxEntries,
T remainingValueKey)
maxEntries - defines the maximum size of the returned MapremainingValueKey - used to map all remaining values that are not top values;
if null, the remaining values are simply dropped from the returned Map
public static <T,N extends Number> HashMap<T,Double> bottomDoubleValues(Map<T,N> data,
int maxEntries,
T remainingValueKey)
maxEntries - defines the maximum size of the returned MapremainingValueKey - used to map all remaining values that are not top values;
if null, the remaining values are simply dropped from the returned Map
public static <T,N extends Number> HashMap<T,Double> aggregatedDoubleValues(Map<T,N> data,
int maxEntries,
T remainingValueKey,
Comparator<Map.Entry<T,N>> comparator)
public static <T> HashMap<T,BigDecimal> topBigDecimalValues(Map<T,? extends Number> data,
int maxEntries,
T remainderKey)
maxEntries - defines the maximum size of the returned MapremainderKey - used to map all remaining values that are not top values;
if null, the remaining values are simply dropped from the returned Map
public static <T> ArrayList<T> extract(Collection<T> col,
Filter<? super T> filter)
public static <T,P> HashMap<P,ArrayList<T>> groupBy(Collection<T> col,
PatternExtractor<? super T,P> extractor,
Filter<? super T> filter)
public static <T,P> HashSet<P> distinctValues(Collection<T> col,
PatternExtractor<? super T,P> extractor,
Filter<? super T> filter)
public static <T,P> HashMap<P,T> map(Collection<T> col,
PatternExtractor<? super T,P> extractor,
Filter<? super T> filter)
public static TreeMap<Date,BigDecimal> groupAndFill(Map<Date,? extends Number> data,
TimeInterval interval)
throws IllegalArgumentException
BigDecimal.ZERO.
IllegalArgumentExceptionpublic static <K,V> HashMap<V,K> reverseMap(Map<K,V> map)
public static <K,V> K keyForValue(Map<K,V> map,
V value)
public static <K,V> Set<K> keysForValue(Map<K,V> map,
V value)
public static <K,C,V extends Comparable<C>> SortedMap<K,V> sortByValues(Map<K,V> map)
public static <K,C,V extends Comparable<C>> SortedMap<K,V> sortByValues(Map<K,V> map,
boolean ascending)
public static <K,V> SortedMap<K,V> sortByValues(Map<K,V> map,
Comparator<? super V> comparator)
public static <T> int indexOf(T obj,
Collection<T> col,
Discriminator<T> d)
public static <T> HashSet<T> makeSet(T[] array)
throws IllegalArgumentException
IllegalArgumentException - if the array contains duplicates
public static <T> HashSet<T> makeSet(T[] array,
boolean ignoreDuplicates)
throws IllegalArgumentException
IllegalArgumentException - if the array contains duplicates and ignoreDuplicates is false
public static <T> HashSet<T> difference(Collection<? extends T> set1,
Collection<? extends T> set2)
public static boolean same(Map<?,?> m1,
Map<?,?> m2)
public static void verifyCollection(Collection<?> col,
Class<?> type)
throws InconsistentContentException
col - the collection to be verifiedtype - the class that is required to be a superclass of every element of the given collection
InconsistentContentException - if one element is not a subclass of the given typepublic static <T> T randomElement(Collection<T> col)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||