本文整理汇总了Java中java.util.function.IntToLongFunction.applyAsLong方法的典型用法代码示例。如果您正苦于以下问题:Java IntToLongFunction.applyAsLong方法的具体用法?Java IntToLongFunction.applyAsLong怎么用?Java IntToLongFunction.applyAsLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.function.IntToLongFunction
的用法示例。
在下文中一共展示了IntToLongFunction.applyAsLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupRandomIndexes
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
static long lookupRandomIndexes(IntToLongFunction func) {
long sumOfIndexes = 0;
Random r = new Random(31);
for (int i = 0; i < LOOKUPS; i++) {
int index = 1 + r.nextInt(10);
sumOfIndexes += func.applyAsLong(index);
}
return sumOfIndexes;
}
示例2: F
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
F(IntToLongFunction intToLongFunction) {
this((Function<T, R>) new Function<Integer, Long>() {
@Override
public Long apply(Integer t) {
return intToLongFunction.applyAsLong(t);
}
});
}
示例3: setAll
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Set all elements of the specified array, using the provided
* generator function to compute each element.
*
* <p>If the generator function throws an exception, it is relayed to
* the caller and the array is left in an indeterminate state.
*
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
* @throws NullPointerException if the generator is null
* @since 1.8
*/
public static void setAll(long[] array, IntToLongFunction generator) {
Objects.requireNonNull(generator);
for (int i = 0; i < array.length; i++)
array[i] = generator.applyAsLong(i);
}
示例4: setAll
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Set all elements of the specified array, using the provided
* generator function to compute each element.
*
* <p>If the generator function throws an exception, it is relayed to
* the caller and the array is left in an indeterminate state.
*
* @apiNote
* Setting a subrange of an array, using a generator function to compute
* each element, can be written as follows:
* <pre>{@code
* IntStream.range(startInclusive, endExclusive)
* .forEach(i -> array[i] = generator.applyAsLong(i));
* }</pre>
*
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
* @throws NullPointerException if the generator is null
* @since 1.8
*/
public static void setAll(long[] array, IntToLongFunction generator) {
Objects.requireNonNull(generator);
for (int i = 0; i < array.length; i++)
array[i] = generator.applyAsLong(i);
}
示例5: onlyThird
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Creates a {@link TriIntToLongFunction} which uses the {@code third} parameter of this one as argument for the
* given {@link IntToLongFunction}.
*
* @param function The function which accepts the {@code third} parameter of this one
* @return Creates a {@code TriIntToLongFunction} which uses the {@code third} parameter of this one as argument for
* the given {@code IntToLongFunction}.
* @throws NullPointerException If given argument is {@code null}
*/
@Nonnull
static TriIntToLongFunction onlyThird(@Nonnull final IntToLongFunction function) {
Objects.requireNonNull(function);
return (value1, value2, value3) -> function.applyAsLong(value3);
}
示例6: onlySecond
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Creates a {@link ObjIntToLongFunction} which uses the {@code second} parameter of this one as argument for the
* given {@link IntToLongFunction}.
*
* @param <T> The type of the first argument to the function
* @param function The function which accepts the {@code second} parameter of this one
* @return Creates a {@code ObjIntToLongFunction} which uses the {@code second} parameter of this one as argument
* for the given {@code IntToLongFunction}.
* @throws NullPointerException If given argument is {@code null}
*/
@Nonnull
static <T> ObjIntToLongFunction<T> onlySecond(@Nonnull final IntToLongFunction function) {
Objects.requireNonNull(function);
return (t, value) -> function.applyAsLong(value);
}
示例7: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link ShortToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
* the caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive function to an operation returning {@code long}.
*
* @param after The function to apply after this function is applied
* @return A composed {@code ShortToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default ShortToLongFunction andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (value) -> after.applyAsLong(applyAsInt(value));
}
示例8: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link DoubleToLongFunction2} that first applies this function to its input, and then applies
* the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
* the caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive function to an operation returning {@code long}.
*
* @param after The function to apply after this function is applied
* @return A composed {@code DoubleToLongFunction2} that first applies this function to its input, and then applies
* the {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default DoubleToLongFunction2 andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (value) -> after.applyAsLong(applyAsInt(value));
}
示例9: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link IntToLongFunction2} that first applies this operator to its input, and then applies the
* {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to the
* caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive operator to an operation returning {@code long}.
*
* @param after The function to apply after this operator is applied
* @return A composed {@code IntToLongFunction2} that first applies this operator to its input, and then applies the
* {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default IntToLongFunction2 andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (value) -> after.applyAsLong(applyAsInt(value));
}
示例10: onlyFirst
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Creates a {@link TriIntToLongFunction} which uses the {@code first} parameter of this one as argument for the
* given {@link IntToLongFunction}.
*
* @param function The function which accepts the {@code first} parameter of this one
* @return Creates a {@code TriIntToLongFunction} which uses the {@code first} parameter of this one as argument for
* the given {@code IntToLongFunction}.
* @throws NullPointerException If given argument is {@code null}
*/
@Nonnull
static TriIntToLongFunction onlyFirst(@Nonnull final IntToLongFunction function) {
Objects.requireNonNull(function);
return (value1, value2, value3) -> function.applyAsLong(value1);
}
示例11: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link BooleanToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
* the caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive function to an operation returning {@code long}.
*
* @param after The function to apply after this function is applied
* @return A composed {@code BooleanToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default BooleanToLongFunction andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (value) -> after.applyAsLong(applyAsInt(value));
}
示例12: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link BiObjLongToLongFunction} that first applies this function to its input, and then
* applies the {@code after} function to the result. If evaluation of either operation throws an exception, it is
* relayed to the caller of the composed operation. This method is just convenience, to provide the ability to
* transform this primitive function to an operation returning {@code long}.
*
* @param after The function to apply after this function is applied
* @return A composed {@code BiObjLongToLongFunction} that first applies this function to its input, and then
* applies the {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default BiObjLongToLongFunction<T, U> andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (t, u, value) -> after.applyAsLong(applyAsInt(t, u, value));
}
示例13: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link LongSupplier2} that first applies this supplier to its input, and then applies the
* {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to the
* caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive supplier to an operation returning {@code long}.
*
* @param after The function to apply after this supplier is applied
* @return A composed {@code LongSupplier2} that first applies this supplier to its input, and then applies the
* {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default LongSupplier2 andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return () -> after.applyAsLong(getAsInt());
}
示例14: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link FloatToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
* the caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive function to an operation returning {@code long}.
*
* @param after The function to apply after this function is applied
* @return A composed {@code FloatToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default FloatToLongFunction andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (value) -> after.applyAsLong(applyAsInt(value));
}
示例15: andThenToLong
import java.util.function.IntToLongFunction; //导入方法依赖的package包/类
/**
* Returns a composed {@link BiObjIntToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result. If evaluation of either operation throws an exception, it is relayed to
* the caller of the composed operation. This method is just convenience, to provide the ability to transform this
* primitive function to an operation returning {@code long}.
*
* @param after The function to apply after this function is applied
* @return A composed {@code BiObjIntToLongFunction} that first applies this function to its input, and then applies
* the {@code after} function to the result.
* @throws NullPointerException If given argument is {@code null}
* @implSpec The input argument of this method is a able to return primitive values. In this case this is {@code
* long}.
*/
@Nonnull
default BiObjIntToLongFunction<T, U> andThenToLong(@Nonnull final IntToLongFunction after) {
Objects.requireNonNull(after);
return (t, u, value) -> after.applyAsLong(applyAsInt(t, u, value));
}