public final class CollectionUtil
extends java.lang.Object
Collections,
Arrays| Modifier and Type | Method and Description |
|---|---|
static <E> void |
addAll(java.util.Collection<E> pCollection,
java.util.Iterator<? extends E> pIterator)
Adds all elements of the iterator to the collection.
|
static <K,V> java.util.Map<V,K> |
invert(java.util.Map<K,V> pSource)
Creates an inverted mapping of the key/value pairs in the given map.
|
static <K,V> java.util.Map<V,K> |
invert(java.util.Map<K,V> pSource,
java.util.Map<V,K> pResult,
DuplicateHandler<K> pHandler)
Creates an inverted mapping of the key/value pairs in the given map.
|
static <E> java.util.ListIterator<E> |
iterator(E[] pArray)
Creates a thin
Iterator wrapper around an array. |
static <E> java.util.ListIterator<E> |
iterator(E[] pArray,
int pStart,
int pLength)
Creates a thin
Iterator wrapper around an array. |
static <T> java.util.Iterator<T> |
iterator(java.util.Enumeration<T> pEnum) |
static void |
main(java.lang.String[] pArgs)
Testing only.
|
static java.lang.Object |
mergeArrays(java.lang.Object pArray1,
int pOffset1,
int pLength1,
java.lang.Object pArray2,
int pOffset2,
int pLength2)
Merges two arrays into a new array.
|
static java.lang.Object |
mergeArrays(java.lang.Object pArray1,
java.lang.Object pArray2)
Merges two arrays into a new array.
|
static <T> java.util.Comparator<T> |
reverseOrder(java.util.Comparator<T> pOriginal) |
static java.lang.Object |
subArray(java.lang.Object pArray,
int pStart)
Creates an array containing a subset of the original array.
|
static java.lang.Object |
subArray(java.lang.Object pArray,
int pStart,
int pLength)
Creates an array containing a subset of the original array.
|
static <T> T[] |
subArray(T[] pArray,
int pStart)
Creates an array containing a subset of the original array.
|
static <T> T[] |
subArray(T[] pArray,
int pStart,
int pLength)
Creates an array containing a subset of the original array.
|
public static void main(java.lang.String[] pArgs)
pArgs - command line arguentspublic static java.lang.Object mergeArrays(java.lang.Object pArray1,
java.lang.Object pArray2)
pArray1 - First arraypArray2 - Second array, must be compatible with (assignable from)
the first arraymergeArrays(Object,int,int,Object,int,int),
System.arraycopy(Object,int,Object,int,int)public static java.lang.Object mergeArrays(java.lang.Object pArray1,
int pOffset1,
int pLength1,
java.lang.Object pArray2,
int pOffset2,
int pLength2)
pArray1 - First arraypOffset1 - the offset into the first arraypLength1 - the number of elements to copy from the first arraypArray2 - Second array, must be compatible with (assignable from)
the first arraypOffset2 - the offset into the second arraypLength2 - the number of elements to copy from the second arraySystem.arraycopy(Object,int,Object,int,int)public static java.lang.Object subArray(java.lang.Object pArray,
int pStart)
pStart == 0), the original array will be returned.pArray - the original arraypStart - the start index of the original arraypStart is 0.java.lang.IllegalArgumentException - if pArray is null or
if pArray is not an array.java.lang.ArrayIndexOutOfBoundsException - if pStart < 0public static <T> T[] subArray(T[] pArray,
int pStart)
pStart == 0), the original array will be returned.T - the type of arraypArray - the original arraypStart - the start index of the original arraypStart is 0.java.lang.IllegalArgumentException - if pArray is nulljava.lang.ArrayIndexOutOfBoundsException - if pStart < 0public static java.lang.Object subArray(java.lang.Object pArray,
int pStart,
int pLength)
pLength parameter is negative, it will be ignored.
If there are not pLength elements in the original array
after pStart, the pLength parameter will be
ignored.
If the sub array is same length as the original, the original array will
be returned.pArray - the original arraypStart - the start index of the original arraypLength - the length of the new arraypStart is 0 and pLength is either
negative, or greater or equal to pArray.length.java.lang.IllegalArgumentException - if pArray is null or
if pArray is not an array.java.lang.ArrayIndexOutOfBoundsException - if pStart < 0public static <T> T[] subArray(T[] pArray,
int pStart,
int pLength)
pLength parameter is negative, it will be ignored.
If there are not pLength elements in the original array
after pStart, the pLength parameter will be
ignored.
If the sub array is same length as the original, the original array will
be returned.T - the type of arraypArray - the original arraypStart - the start index of the original arraypLength - the length of the new arraypStart is 0 and pLength is either
negative, or greater or equal to pArray.length.java.lang.IllegalArgumentException - if pArray is nulljava.lang.ArrayIndexOutOfBoundsException - if pStart < 0public static <T> java.util.Iterator<T> iterator(java.util.Enumeration<T> pEnum)
public static <E> void addAll(java.util.Collection<E> pCollection,
java.util.Iterator<? extends E> pIterator)
pCollection - the collectionpIterator - the elements to addjava.lang.UnsupportedOperationException - if add is not supported by
the given collection.java.lang.ClassCastException - class of the specified element prevents it
from being added to this collection.java.lang.NullPointerException - if the specified element is null and this
collection does not support null elements.java.lang.IllegalArgumentException - some aspect of this element prevents
it from being added to this collection.public static <E> java.util.ListIterator<E> iterator(E[] pArray)
Iterator wrapper around an array.pArray - the array to iterateListIteratorjava.lang.IllegalArgumentException - if pArray is null,
pStart < 0, or
pLength > pArray.length - pStartpublic static <E> java.util.ListIterator<E> iterator(E[] pArray,
int pStart,
int pLength)
Iterator wrapper around an array.pArray - the array to iteratepStart - the offset into the arraypLength - the number of elements to include in the iteratorListIteratorjava.lang.IllegalArgumentException - if pArray is null,
pStart < 0, or
pLength > pArray.length - pStartpublic static <K,V> java.util.Map<V,K> invert(java.util.Map<K,V> pSource)
pSource - the source mapMap of same type as pSourcejava.lang.IllegalArgumentException - if pSource == null,
or if a new map can't be instantiated,
or if source map contains duplicates.invert(java.util.Map, java.util.Map, DuplicateHandler)public static <K,V> java.util.Map<V,K> invert(java.util.Map<K,V> pSource,
java.util.Map<V,K> pResult,
DuplicateHandler<K> pHandler)
pSource - the source mappResult - the map used to contain the result, may be null,
in that case a new Map of same type as pSource is created.
The result map should be empty, otherwise duplicate values will need to be resolved.pHandler - duplicate handler, may be null if source map don't contain duplicate valuespResult, or a new Map if pResult == nulljava.lang.IllegalArgumentException - if pSource == null,
or if result map is null and a new map can't be instantiated,
or if source map contains duplicate values and pHandler == null.public static <T> java.util.Comparator<T> reverseOrder(java.util.Comparator<T> pOriginal)
Copyright © 2020. All Rights Reserved.