本文整理匯總了Java中java.util.function.ToLongFunction.applyAsLong方法的典型用法代碼示例。如果您正苦於以下問題:Java ToLongFunction.applyAsLong方法的具體用法?Java ToLongFunction.applyAsLong怎麽用?Java ToLongFunction.applyAsLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.function.ToLongFunction
的用法示例。
在下文中一共展示了ToLongFunction.applyAsLong方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toLong
import java.util.function.ToLongFunction; //導入方法依賴的package包/類
/**
* Creates an LONG mapper that wraps to function provided
* @param function the function to wrap
* @param <I> the input type
* @return the newly created mapper
*/
public static <I,O> Function1<I,Long> toLong(ToLongFunction<I> function) {
return new Function1<I,Long>(FunctionStyle.LONG) {
@Override
public final long applyAsLong(I value) {
return function.applyAsLong(value);
}
};
}
示例2: DefaultCardinalityEstimator
import java.util.function.ToLongFunction; //導入方法依賴的package包/類
public DefaultCardinalityEstimator(double certaintyProb,
int numInputs,
boolean isAllowMoreInputs,
ToLongFunction<long[]> singlePointEstimator) {
this(certaintyProb,
numInputs,
isAllowMoreInputs,
(inputCards, rheemContext) -> singlePointEstimator.applyAsLong(inputCards));
}
示例3: lop
import java.util.function.ToLongFunction; //導入方法依賴的package包/類
private static long lop(Row row, String name, ToLongFunction<Row> f) {
if (row.getColumnDefinitions().contains(name)) {
return f.applyAsLong(row);
} else {
return 0;
}
}
示例4: summingLong
import java.util.function.ToLongFunction; //導入方法依賴的package包/類
/**
* Returns a {@code Collector} that produces the sum of a long-valued
* function applied to the input elements. If no elements are present,
* the result is 0.
*
* @param <T> the type of the input elements
* @param mapper a function extracting the property to be summed
* @return a {@code Collector} that produces the sum of a derived property
*/
public static <T> Collector<T, ?, Long>
summingLong(ToLongFunction<? super T> mapper) {
return new CollectorImpl<>(
() -> new long[1],
(a, t) -> { a[0] += mapper.applyAsLong(t); },
(a, b) -> { a[0] += b[0]; return a; },
a -> a[0], CH_NOID);
}
示例5: averagingLong
import java.util.function.ToLongFunction; //導入方法依賴的package包/類
/**
* Returns a {@code Collector} that produces the arithmetic mean of a long-valued
* function applied to the input elements. If no elements are present,
* the result is 0.
*
* @param <T> the type of the input elements
* @param mapper a function extracting the property to be summed
* @return a {@code Collector} that produces the sum of a derived property
*/
public static <T> Collector<T, ?, Double>
averagingLong(ToLongFunction<? super T> mapper) {
return new CollectorImpl<>(
() -> new long[2],
(a, t) -> { a[0] += mapper.applyAsLong(t); a[1]++; },
(a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; },
a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID);
}
示例6: averagingLong
import java.util.function.ToLongFunction; //導入方法依賴的package包/類
/**
* Returns a {@code Collector} that produces the arithmetic mean of a long-valued
* function applied to the input elements. If no elements are present,
* the result is 0.
*
* @param <T> the type of the input elements
* @param mapper a function extracting the property to be averaged
* @return a {@code Collector} that produces the arithmetic mean of a
* derived property
*/
public static <T> Collector<T, ?, Double>
averagingLong(ToLongFunction<? super T> mapper) {
return new CollectorImpl<>(
() -> new long[2],
(a, t) -> { a[0] += mapper.applyAsLong(t); a[1]++; },
(a, b) -> { a[0] += b[0]; a[1] += b[1]; return a; },
a -> (a[1] == 0) ? 0.0d : (double) a[0] / a[1], CH_NOID);
}