当前位置: 首页>>代码示例>>Java>>正文


Java ObjLongConsumer.accept方法代码示例

本文整理汇总了Java中java.util.function.ObjLongConsumer.accept方法的典型用法代码示例。如果您正苦于以下问题:Java ObjLongConsumer.accept方法的具体用法?Java ObjLongConsumer.accept怎么用?Java ObjLongConsumer.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.function.ObjLongConsumer的用法示例。


在下文中一共展示了ObjLongConsumer.accept方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeLong

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code long} values.
 *
 * @param <R> the type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return a {@code TerminalOp} implementing the reduction
 */
public static <R> TerminalOp<Long, R>
makeLong(Supplier<R> supplier,
         ObjLongConsumer<R> accumulator,
         BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Long, R, ReducingSink>, Sink.OfLong {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(long t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Long, R, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:ReduceOps.java

示例2: F

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
F(ObjLongConsumer<T1> objLongConsumer) {
    this((BiFunction<T1, T2, R>) new BiFunction<T1, Long, R>() {
        @Override
        public R apply(T1 t, Long u) {
            objLongConsumer.accept(t, u);
            return null;
        }
    });
}
 
开发者ID:codebulb,项目名称:LambdaOmega,代码行数:10,代码来源:F.java

示例3: collect

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
@Override
public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
    requireNonNull(supplier);
    requireNonNull(accumulator);
    final R value = supplier.get();
    accumulator.accept(value, element);
    // the combiner is never used in a non-parallell stream
    return value;
}
 
开发者ID:speedment,项目名称:speedment,代码行数:10,代码来源:SingletonLongStream.java

示例4: assertObjLongConsumer

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
private <E extends Exception> void assertObjLongConsumer(ObjLongConsumer<Object> test, Class<E> type) {
    assertNotNull(test);
    try {
        test.accept(null, 0L);
        fail();
    } 
    catch (Exception e) {
        assertException(type, e, "null:0");
    }
}
 
开发者ID:jOOQ,项目名称:jOOL,代码行数:11,代码来源:CheckedBiConsumerTest.java

示例5: andThen

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
/**
 * Returns a composed {@link ObjLongConsumer2} that performs, in sequence, this consumer followed by the {@code
 * after} consumer. If evaluation of either operation throws an exception, it is relayed to the caller of the
 * composed operation. If performing this consumer throws an exception, the {@code after} consumer will not be
 * performed.
 *
 * @param after The consumer to apply after this consumer is applied
 * @return A composed {@link ObjLongConsumer2} that performs, in sequence, this consumer followed by the {@code
 * after} consumer.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
default ObjLongConsumer2<T> andThen(@Nonnull final ObjLongConsumer<? super T> after) {
    Objects.requireNonNull(after);
    return (t, value) -> {
        accept(t, value);
        after.accept(t, value);
    };
}
 
开发者ID:gridtec,项目名称:lambda4j,代码行数:20,代码来源:ObjLongConsumer2.java

示例6: partitioningBy

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
/**
 * Returns a {@code LongCollector} which partitions the input numbers
 * according to a {@code LongPredicate}, reduces the values in each
 * partition according to another {@code IntCollector}, and organizes them
 * into a {@code Map<Boolean, D>} whose values are the result of the
 * downstream reduction.
 *
 * <p>
 * There are no guarantees on the type, mutability, serializability, or
 * thread-safety of the {@code Map} returned.
 *
 * @param <A> the intermediate accumulation type of the downstream collector
 * @param <D> the result type of the downstream reduction
 * @param predicate a predicate used for classifying input elements
 * @param downstream a {@code LongCollector} implementing the downstream
 *        reduction
 * @return a {@code LongCollector} implementing the cascaded partitioning
 *         operation
 */
static <A, D> LongCollector<?, Map<Boolean, D>> partitioningBy(LongPredicate predicate,
        LongCollector<A, D> downstream) {
    ObjLongConsumer<A> downstreamAccumulator = downstream.longAccumulator();
    ObjLongConsumer<BooleanMap<A>> accumulator = (result, t) -> downstreamAccumulator.accept(
        predicate.test(t) ? result.trueValue : result.falseValue, t);
    return BooleanMap.partialCollector(downstream).asLong(accumulator);
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:27,代码来源:LongCollector.java

示例7: call

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
/**
 * Calls the given {@link ObjLongConsumer} with the given arguments and returns its result.
 *
 * @param <T> The type of the first argument to the consumer
 * @param consumer The consumer to be called
 * @param t The first argument to the consumer
 * @param value The second argument to the consumer
 * @throws NullPointerException If given argument is {@code null}
 */
static <T> void call(@Nonnull final ObjLongConsumer<? super T> consumer, T t, long value) {
    Objects.requireNonNull(consumer);
    consumer.accept(t, value);
}
 
开发者ID:gridtec,项目名称:lambda4j,代码行数:14,代码来源:ObjLongConsumer2.java

示例8: mapping

import java.util.function.ObjLongConsumer; //导入方法依赖的package包/类
/**
 * Adapts a {@code LongCollector} to another one by applying a mapping
 * function to each input element before accumulation.
 *
 * @param <A> intermediate accumulation type of the downstream collector
 * @param <R> result type of collector
 * @param mapper a function to be applied to the input elements
 * @param downstream a collector which will accept mapped values
 * @return a collector which applies the mapping function to the input
 *         elements and provides the mapped results to the downstream
 *         collector
 */
static <A, R> LongCollector<?, R> mapping(LongUnaryOperator mapper, LongCollector<A, R> downstream) {
    ObjLongConsumer<A> downstreamAccumulator = downstream.longAccumulator();
    return new LongCollectorImpl<>(downstream.supplier(), (r, t) -> downstreamAccumulator.accept(r, mapper
            .applyAsLong(t)), downstream.merger(), downstream.finisher(), downstream.characteristics());
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:18,代码来源:LongCollector.java


注:本文中的java.util.function.ObjLongConsumer.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。