/** * Returns a counter view of the given map. Infers the numeric type of the * values from the first element in map.values(). */ @SuppressWarnings("unchecked") public static <E, N extends Number> Counter<E> fromMap(final Map<E, N> map) { if (map.isEmpty()) { throw new IllegalArgumentException("Map must have at least one element" + " to infer numeric type; add an element first or use e.g." + " fromMap(map, Integer.class)"); } return fromMap(map, (Class) map.values().iterator().next().getClass()); }
/** * Returns a counter view of the given map. Infers the numeric type of the * values from the first element in map.values(). */ @SuppressWarnings("unchecked") public static <E, N extends Number> Counter<E> fromMap(final Map<E, N> map) { if (map.isEmpty()) { throw new IllegalArgumentException("Map must have at least one element" + " to infer numeric type; add an element first or use e.g." + " fromMap(map, Integer.class)"); } return fromMap(map, (Class) map.values().iterator().next().getClass()); }
/** * Returns a counter view of the given map. Infers the numeric type of the * values from the first element in map.values(). */ @SuppressWarnings("unchecked") public static <E, N extends Number> Counter<E> fromMap(final Map<E, N> map) { if (map.isEmpty()) { throw new IllegalArgumentException("Map must have at least one element" + " to infer numeric type; add an element first or use e.g." + " fromMap(map, Integer.class)"); } return fromMap(map, (Class) map.values().iterator().next().getClass()); }
/** * Returns a counter view of the given map. Infers the numeric type of the * values from the first element in map.values(). */ @SuppressWarnings("unchecked") public static <E, N extends Number> Counter<E> fromMap(final Map<E, N> map) { if (map.isEmpty()) { throw new IllegalArgumentException("Map must have at least one element" + " to infer numeric type; add an element first or use e.g." + " fromMap(map, Integer.class)"); } return fromMap(map, (Class) map.values().iterator().next().getClass()); }
/** * Returns a counter view of the given map. Infers the numeric type * of the values from the first element in map.values(). */ @SuppressWarnings("unchecked") public static <E, N extends Number> Counter<E> fromMap(final Map<E,N> map) { if (map.isEmpty()) { throw new IllegalArgumentException("Map must have at least one element" + " to infer numeric type; add an element first or use e.g." + " fromMap(map, Integer.class)"); } return fromMap(map, (Class)map.values().iterator().next().getClass()); }