2021-06-03 01:33:20 +00:00
|
|
|
package uulm.teamname.marvelous.gamelibrary;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2021-06-03 17:33:14 +00:00
|
|
|
import java.util.Arrays;
|
2021-06-03 01:33:20 +00:00
|
|
|
|
|
|
|
/** Provides various tools for Arrays. */
|
|
|
|
public class ArrayTools {
|
|
|
|
/**
|
|
|
|
* Returns a variable-size array list backed by the specified array without allocating more memory than necessary.
|
|
|
|
* @param <E> the class of the objects in the array
|
|
|
|
* @param a the array by which the list will be backed
|
|
|
|
* @return a list view of the specified array
|
|
|
|
* @throws NullPointerException if the specified array is {@code null}
|
|
|
|
*/
|
|
|
|
public static <E> ArrayList<E> toArrayList(E[] a) {
|
|
|
|
ArrayList<E> l = new ArrayList<>(a.length);
|
2021-06-03 17:33:14 +00:00
|
|
|
l.addAll(Arrays.asList(a));
|
2021-06-03 01:33:20 +00:00
|
|
|
return l;
|
|
|
|
}
|
|
|
|
}
|