Package one.microstream.collections.old
Class OldCollections
java.lang.Object
one.microstream.collections.old.OldCollections
public final class OldCollections extends Object
Some utility functionality for the old, misdesigned, bugged JDK collections that is so obvious but still
missing in the JDK that even got implemented here despite having a vastly superior collections framework.
-
Method Summary
Modifier and Type Method Description static <C extends Collection<? super E>, E>
CaddArray(C collection, E... elements)static <C extends Collection<T>, T>
CaddBatch(C c, Iterable<T> elements)static <C extends Collection<T>, T>
Cappend(C collectionToEnhance, Predicate<? super T> selectionPredicate, Iterable<T> collectionToAppend)static <C extends Collection<T>, T>
Cappend(C collectionToEnhance, Predicate<? super T> selectionPredicate, Iterator<T> iterator)static <C extends Collection<T>, T>
Cappend(C collectionToEnhance, Predicate<? super T> selectionPredicate, T[] arrayToAppend)static StringBuilderappendArray(StringBuilder sb, Object... elements)static StringBuilderappendArraySeperated(StringBuilder sb, char elementSeperator, Object... elements)static StringBuilderappendArraySeperated(StringBuilder sb, String elementSeperator, Object... elements)static StringBuilderappendIterable(StringBuilder sb, Iterable<?> iterable)static StringBuilderappendIterableSeperated(StringBuilder sb, char elementSeperator, Iterable<?> iterable)static StringBuilderappendIterableSeperated(StringBuilder sb, String elementSeperator, Iterable<?> iterable)static <T> ArrayList<T>ArrayList(int initialCapacity, Iterable<T> elements)static <E> ArrayList<E>ArrayList(E... elements)static <E> ArrayList<E>ArrayList(XGettingCollection<? extends E> xCollection)Convenience method fornew ArrayList<E>(xCollection).static <T, L extends List<T> & RandomAccess>
booleancontainsSearched(L list, Predicate<? super T> predicate)static <T, L extends List<T> & RandomAccess>
intcount(L list, Predicate<? super T> predicate)static <C extends Collection<T>, T>
Cfilter(C sourceCollection, Predicate<? super T> selectionPredicate, C target)static <T> ArrayList<T>filter(ArrayList<T> arrayList, Predicate<? super T> selectionPredicate)static <T, L extends List<T> & RandomAccess>
Lfilter(L list, Predicate<? super T> selectionPredicate, L targetList)static <E> LinkedList<E>LinkedList(E... elements)static <E> LinkedList<E>LinkedList(XGettingCollection<? extends E> xCollection)static <K, V, T extends Map<K, V>, S extends Map<? extends K, ? extends V>>
TmergeInto(T target, S... maps)static <K, V> HashMap<K,V>OldHashMap(KeyValue<? extends K,? extends V>... keyValueTuples)static <T> HashSet<T>OldHashSet(T... elements)static <K, V> LinkedHashMap<K,V>OldLinkedHashMap(XGettingMap<K,V> map)static voidpopulateCollection(Collection<Object> instance, Object[] elements)static voidpopulateCollectionFromHelperArray(Collection<?> instance, Object elementsHelper)static voidpopulateMap(Map<Object,Object> instance, Object[] elements)static voidpopulateMapFromHelperArray(Map<?,?> instance, Object elementsHelper)static <C extends Collection<T>, T>
Creduce(C collection, Predicate<? super T> reductionPredicate)Reducescollectionby all elements that meetreductionPredicate.
Note that NO new collection instance is created but the collection itself is reduced.static <T> ArrayList<T>reduce(ArrayList<T> arrayList, Predicate<? super T> reductionPredicate)static <T, L extends List<T> & RandomAccess>
Tsearch(L list, Predicate<? super T> predicate)static StringBuilderstringBuilder(Object... elements)static StringBuilderstringBuilderSeperated(char elementSeperator, Object... elements)static StringBuilderstringBuilderSeperated(String elementSeperator, Object... elements)static <T> T[]toArray(Collection<? extends T> collection, Class<T> elementType)Alias for the annoyingcollection.toArray((T[])Array.newInstance(elementType, collection.size()))
-
Method Details
-
addBatch
-
addArray
@SafeVarargs public static final <C extends Collection<? super E>, E> C addArray(C collection, E... elements) -
ArrayList
-
ArrayList
-
LinkedList
-
LinkedList
-
mergeInto
@SafeVarargs public static <K, V, T extends Map<K, V>, S extends Map<? extends K, ? extends V>> T mergeInto(T target, S... maps) -
count
public static final <T, L extends List<T> & RandomAccess> int count(L list, Predicate<? super T> predicate) -
search
public static final <T, L extends List<T> & RandomAccess> T search(L list, Predicate<? super T> predicate) -
containsSearched
public static final <T, L extends List<T> & RandomAccess> boolean containsSearched(L list, Predicate<? super T> predicate) -
append
public static <C extends Collection<T>, T> C append(C collectionToEnhance, Predicate<? super T> selectionPredicate, T[] arrayToAppend) -
append
public static <C extends Collection<T>, T> C append(C collectionToEnhance, Predicate<? super T> selectionPredicate, Iterator<T> iterator) -
append
public static <C extends Collection<T>, T> C append(C collectionToEnhance, Predicate<? super T> selectionPredicate, Iterable<T> collectionToAppend) -
filter
-
filter
public static <T, L extends List<T> & RandomAccess> L filter(L list, Predicate<? super T> selectionPredicate, L targetList) -
filter
public static <C extends Collection<T>, T> C filter(C sourceCollection, Predicate<? super T> selectionPredicate, C target) -
reduce
-
reduce
public static <C extends Collection<T>, T> C reduce(C collection, Predicate<? super T> reductionPredicate)Reducescollectionby all elements that meetreductionPredicate.
Note that NO new collection instance is created but the collection itself is reduced.- Type Parameters:
T-- Parameters:
collection- the collection to be reducedreductionPredicate- the predicate determining which elements shall be removed- Returns:
collectionitself
-
appendIterableSeperated
public static final StringBuilder appendIterableSeperated(StringBuilder sb, String elementSeperator, Iterable<?> iterable) -
appendIterableSeperated
public static final StringBuilder appendIterableSeperated(StringBuilder sb, char elementSeperator, Iterable<?> iterable) -
appendIterable
-
appendArraySeperated
public static final StringBuilder appendArraySeperated(StringBuilder sb, String elementSeperator, Object... elements) -
appendArraySeperated
public static final StringBuilder appendArraySeperated(StringBuilder sb, char elementSeperator, Object... elements) -
appendArray
-
stringBuilderSeperated
public static final StringBuilder stringBuilderSeperated(String elementSeperator, Object... elements) -
stringBuilderSeperated
public static final StringBuilder stringBuilderSeperated(char elementSeperator, Object... elements) -
stringBuilder
-
toArray
Alias for the annoyingcollection.toArray((T[])Array.newInstance(elementType, collection.size()))- Type Parameters:
T- the element type parameter of the list- Parameters:
collection- the collection whose elements shall be copied to an arrayelementType- the type of the elements contained incollection.- Returns:
- a new array object of type
containing all elements of collection.
-
OldHashSet
-
OldHashMap
@SafeVarargs public static <K, V> HashMap<K,V> OldHashMap(KeyValue<? extends K,? extends V>... keyValueTuples) -
OldLinkedHashMap
-
ArrayList
Convenience method fornew ArrayList<E>(xCollection).- Type Parameters:
E- the collection element type.- Parameters:
xCollection- the extended collection implementation whore content shall be copied a newArrayListinstance.- Returns:
- a new
ArrayListinstance containing all elements of the passedXGettingCollection.
-
populateMapFromHelperArray
-
populateMap
-
populateCollectionFromHelperArray
public static final void populateCollectionFromHelperArray(Collection<?> instance, Object elementsHelper) -
populateCollection
-