public static <T> void fill(Map<T,T> map,
T[][] data)
A convenience method to initialize a map from a two-dimensional array.
Each element of the arbitrary length array is itself a two-element array,
the first element being the key, and the second being the value
for the map.
Type Parameters:
T - Generic-type.
Parameters:
map - the Map to fill
data - the two-dimensional array from which to fill the map
fill
public static <T> void fill(Collection<T> c,
T[] data)
A convenience method to initialize a collection from an array.
This lets you say, e.g.
ArrayList a = new ArrayList();
CollectionsPlus.fill(a, new String[] { "", null, "xyz" });
instead of this standard (but little known) language construct:
ArrayList a = new ArrayList() {
{ add(""); add(null); add("xyz"); }
};
The choice is mostly a matter of style.
Type Parameters:
T - Generic-type.
Parameters:
c - Collection to fill
data - the array from which to fill the collection