Package com.norswap.nanoeth.utils
Class Utils
java.lang.Object
com.norswap.nanoeth.utils.Utils
public final class Utils extends Object
Misc general-purpose utilities that do not have a place in other utility classes.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Utils.ThrowingFunction<T,R>
Similar toFunction
, but allowed to throw exceptions. -
Method Summary
Modifier and Type Method Description static <T> boolean
allDistinct(T... values)
Returns true iff all supplies values are distinct.static <T, R> R[]
map(T[] array, IntFunction<R[]> arraySupplier, Function<T,R> f)
Returns an array obtained by applying the functionf
to each item inarray
.static <T, R> R[]
mapThrowing(T[] array, IntFunction<R[]> arraySupplier, Utils.ThrowingFunction<T,R> f)
Returns an array obtained by applying the functionf
to each item inarray
.
-
Method Details
-
allDistinct
Returns true iff all supplies values are distinct. -
map
Returns an array obtained by applying the functionf
to each item inarray
.The returned array is obtained by calling
arraySupplier
with the desired size. -
mapThrowing
public static <T, R> R[] mapThrowing(T[] array, IntFunction<R[]> arraySupplier, Utils.ThrowingFunction<T,R> f) throws ThrowableReturns an array obtained by applying the functionf
to each item inarray
.The returned array is obtained by calling
arraySupplier
with the desired size.- Throws:
Throwable
-