
public final class CollectionUtils extends Object
| Modifier | Constructor and Description |
|---|---|
private |
CollectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <E> void |
forEach(List<E> s,
BiConsumer<? super Integer,? super E> f)
Facility for executing lambdas requiring access to the index.
|
static <E,R> List<R> |
map(List<E> s,
BiFunction<? super Integer,? super E,? extends R> f)
Facility for executing lambdas requiring access to the index.
|
static int |
optimalSizeMap(Collection<?> c)
Computes the size of a map (with 0.75 as load factor) such as the map
does not need to resize itself if all the elements of c are passed.
|
static int |
optimalSizeMap(int n)
Computes the size of a map (with 0.75 as load factor) such as the map
does not need to resize itself if n elements are added.
|
public static int optimalSizeMap(int n)
n - the number of elementspublic static int optimalSizeMap(Collection<?> c)
c - the collection containing the elementspublic static <E> void forEach(List<E> s, BiConsumer<? super Integer,? super E> f)
E - List data types - the List to apply the lambda onf - the BiConsumer to apply to each elementpublic static <E,R> List<R> map(List<E> s, BiFunction<? super Integer,? super E,? extends R> f)
List. Avoid
side effects on the list, they won't work correctly.E - input List data typeR - return List data types - the List to apply the lambda onf - the BiFunction to apply to each elementBiFunction applied to the give List