Java 类java.util.function.ToLongFunction 实例源码

项目:primeval-reflex    文件:RepeatedAnnotationObjectInterceptor.java   
private static <A extends Annotation, E extends Throwable> long callLong(
        AnnotationInterceptor<A> annotationInterceptor,
        int annotationId, A[] annotations, CallContext context, Arguments currentArguments,
        ToLongFunction<Arguments> terminalInvokeFun) throws E {

    A annotation = annotations[annotationId];
    if (annotationId == annotations.length - 1) { // last annotation
        return annotationInterceptor.onCall(annotation, context,
                new SimpleLongInterceptionHandler(currentArguments, terminalInvokeFun));
    } else {
        return annotationInterceptor.onCall(annotation, context,
                new SimpleLongInterceptionHandler(currentArguments,
                        (args) -> callLong(annotationInterceptor, annotationId + 1, annotations, context, args,
                                terminalInvokeFun)));
    }
}
项目:OpenJSharp    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:jdk8u-jdk    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:openjdk-jdk10    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:openjdk-jdk10    文件:BasicTest.java   
public void testLongComparator() {
    Thing[] things = new Thing[longValues.length];
    for (int i=0; i<longValues.length; i++)
        things[i] = new Thing(0, longValues[i], 0.0, null);
    Comparator<Thing> comp = Comparator.comparingLong(new ToLongFunction<Thing>() {
        @Override
        public long applyAsLong(Thing thing) {
            return thing.getLongField();
        }
    });

    assertComparisons(things, comp, comparisons);
}
项目:morpheus-core    文件:XDataFrameContent.java   
/**
 * Maps the specified column to longs using the mapper function provided
 * @param frame     the frame reference
 * @param colKey    the column key to apply mapper function to
 * @param mapper    the mapper function to apply
 * @return          the newly created content, with update column
 */
@SuppressWarnings("unchecked")
final XDataFrameContent<R,C> mapToLongs(XDataFrame<R,C> frame, C colKey, ToLongFunction<DataFrameValue<R,C>> mapper) {
    if (!isColumnStore()) {
        throw new DataFrameException("Cannot apply columns of a transposed DataFrame");
    } else {
        final int rowCount = rowKeys.size();
        final boolean parallel  = frame.isParallel();
        final int colIndex = colKeys.getIndexForKey(colKey);
        return new XDataFrameContent<>(rowKeys, colKeys, true, Mapper.apply(data, parallel, (index, array) -> {
            if (index != colIndex) {
                return array;
            } else {
                final int colOrdinal = colKeys.getOrdinalForKey(colKey);
                final Array<?> targetValues = Array.of(Long.class, array.length());
                final Cursor cursor = new Cursor(frame, rowKeys.isEmpty() ? -1 : 0, colOrdinal);
                for (int i = 0; i < rowCount; ++i) {
                    cursor.atRowOrdinal(i);
                    final long value = mapper.applyAsLong(cursor);
                    targetValues.setLong(cursor.rowIndex, value);
                }
                return targetValues;
            }
        }));
    }
}
项目:openjdk9    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:Java8CN    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:rheem    文件:DefaultCardinalityEstimatorTest.java   
@Test
public void testBinaryInputEstimation() {
    OptimizationContext optimizationContext = mock(OptimizationContext.class);
    when(optimizationContext.getConfiguration()).thenReturn(new Configuration());

    CardinalityEstimate inputEstimate1 = new CardinalityEstimate(50, 60, 0.8);
    CardinalityEstimate inputEstimate2 = new CardinalityEstimate(10, 100, 0.4);

    final ToLongFunction<long[]> singlePointEstimator =
            inputEstimates -> (long) Math.ceil(0.8 * inputEstimates[0] * inputEstimates[1]);

    CardinalityEstimator estimator = new DefaultCardinalityEstimator(
            0.9,
            2,
            false,
            singlePointEstimator
    );

    CardinalityEstimate estimate = estimator.estimate(optimizationContext, inputEstimate1, inputEstimate2);

    Assert.assertEquals(0.9 * 0.4, estimate.getCorrectnessProbability(), 0.001);
    Assert.assertEquals(singlePointEstimator.applyAsLong(new long[]{50, 10}), estimate.getLowerEstimate());
    Assert.assertEquals(singlePointEstimator.applyAsLong(new long[]{60, 100}), estimate.getUpperEstimate());

}
项目:jdk8u_jdk    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:memoization.java    文件:ConcurrentMapBasedToLongFunctionMemoizerTest.java   
/**
*
*/
@Test
@SuppressWarnings(CompilerWarnings.UNCHECKED)
public void shouldUseCallWrappedFunction() {
    // given
    final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>();
    final ToLongFunction<String> function = Mockito.mock(ToLongFunction.class);
    final Function<String, String> keyFunction = Function.identity();

    // when
    final ConcurrentMapBasedToLongFunctionMemoizer<String, String> memoizer = new ConcurrentMapBasedToLongFunctionMemoizer<>(
            cache, keyFunction, function);

    // then
    memoizer.applyAsLong("123");
    Mockito.verify(function).applyAsLong("123");
}
项目:lookaside_java-1.8.0-openjdk    文件:ReferencePipeline.java   
@Override
public final LongStream mapToLong(ToLongFunction<? super P_OUT> mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<P_OUT>(this, StreamShape.REFERENCE,
                                  StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedReference<P_OUT, Long>(sink) {
                @Override
                public void accept(P_OUT u) {
                    downstream.accept(mapper.applyAsLong(u));
                }
            };
        }
    };
}
项目:micrometer    文件:DropwizardMeterRegistry.java   
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    DropwizardFunctionTimer ft = new DropwizardFunctionTimer<>(id, clock, obj, countFunction, totalTimeFunction,
        totalTimeFunctionUnits, getBaseTimeUnit());
    registry.register(hierarchicalName(id), ft.getDropwizardMeter());
    return ft;
}
项目:micrometer    文件:CumulativeFunctionTimer.java   
public CumulativeFunctionTimer(Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction,
                               TimeUnit totalTimeFunctionUnits, TimeUnit baseTimeUnit) {
    this.id = id;
    this.ref = new WeakReference<>(obj);
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
    this.baseTimeUnit = baseTimeUnit;
}
项目:micrometer    文件:StepFunctionTimer.java   
public StepFunctionTimer(Id id, Clock clock, long stepMillis, T obj, ToLongFunction<T> countFunction,
                         ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits, TimeUnit baseTimeUnit) {
    this.id = id;
    this.ref = new WeakReference<>(obj);
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
    this.baseTimeUnit = baseTimeUnit;
    this.count = new StepLong(clock, stepMillis);
    this.total = new StepDouble(clock, stepMillis);
}
项目:micrometer    文件:Metrics.java   
/**
 * A timer that tracks monotonically increasing functions for count and totalTime.
 */
public <T> FunctionTimer timer(String name, Iterable<Tag> tags, T obj,
                               ToLongFunction<T> countFunction,
                               ToDoubleFunction<T> totalTimeFunction,
                               TimeUnit totalTimeFunctionUnits) {
    return globalRegistry.more().timer(name, tags, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits);
}
项目:micrometer    文件:FunctionTimer.java   
private Builder(String name, T obj,
                ToLongFunction<T> countFunction,
                ToDoubleFunction<T> totalTimeFunction,
                TimeUnit totalTimeFunctionUnits) {
    this.name = name;
    this.obj = obj;
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
}
项目:micrometer    文件:CompositeFunctionTimer.java   
CompositeFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction,
                       ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    super(id);
    this.ref = new WeakReference<>(obj);
    this.countFunction = countFunction;
    this.totalTimeFunction = totalTimeFunction;
    this.totalTimeFunctionUnits = totalTimeFunctionUnits;
}
项目:micrometer    文件:StatsdFunctionTimer.java   
StatsdFunctionTimer(Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction,
                    TimeUnit totalTimeFunctionUnits, TimeUnit baseTimeUnit,
                    StatsdLineBuilder lineBuilder, Subscriber<String> publisher) {
    super(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits, baseTimeUnit);
    this.lineBuilder = lineBuilder;
    this.publisher = publisher;
}
项目:micrometer    文件:StatsdMeterRegistry.java   
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    StatsdFunctionTimer ft = new StatsdFunctionTimer<>(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits,
        getBaseTimeUnit(), lineBuilder(id), publisher);
    pollableMeters.add(ft);
    return ft;
}
项目:micrometer    文件:PrometheusMeterRegistry.java   
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnits) {
    MicrometerCollector collector = collectorByName(id, Collector.Type.SUMMARY);
    FunctionTimer ft = new CumulativeFunctionTimer<>(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnits, getBaseTimeUnit());
    List<String> tagValues = tagValues(id);

    collector.add((conventionName, tagKeys) -> Stream.of(
        new Collector.MetricFamilySamples.Sample(conventionName + "_count", tagKeys, tagValues, ft.count()),
        new Collector.MetricFamilySamples.Sample(conventionName + "_sum", tagKeys, tagValues, ft.totalTime(TimeUnit.SECONDS))
    ));

    return ft;
}
项目:primeval-reflex    文件:StackedInterceptor.java   
private static <E extends Throwable> long callLong(int interceptorId, Interceptor[] interceptors,
        CallContext context, Arguments currentArguments, ToLongFunction<Arguments> terminalInvokeFun) throws E {
    Interceptor interceptor = interceptors[interceptorId];
    if (interceptorId == interceptors.length - 1) { // last interceptor
        return interceptor.onCall(context, new SimpleLongInterceptionHandler(currentArguments, terminalInvokeFun));
    } else {
        return interceptor.onCall(context, new SimpleLongInterceptionHandler(currentArguments,
                (args) -> callLong(interceptorId + 1, interceptors, context, args, terminalInvokeFun)));
    }
}
项目:OpenJSharp    文件:ConcurrentHashMap.java   
MapReduceKeysToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceKeysToLongTask<K,V> nextRight,
     ToLongFunction<? super K> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:OpenJSharp    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<? super K> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceKeysToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p.key));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceKeysToLongTask<K,V>
                t = (MapReduceKeysToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:OpenJSharp    文件:ConcurrentHashMap.java   
MapReduceValuesToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceValuesToLongTask<K,V> nextRight,
     ToLongFunction<? super V> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:OpenJSharp    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<? super V> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceValuesToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p.val));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceValuesToLongTask<K,V>
                t = (MapReduceValuesToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:OpenJSharp    文件:ConcurrentHashMap.java   
MapReduceEntriesToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceEntriesToLongTask<K,V> nextRight,
     ToLongFunction<Map.Entry<K,V>> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:OpenJSharp    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<Map.Entry<K,V>> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceEntriesToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceEntriesToLongTask<K,V>
                t = (MapReduceEntriesToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:jdk8u-jdk    文件:ConcurrentHashMap.java   
MapReduceKeysToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceKeysToLongTask<K,V> nextRight,
     ToLongFunction<? super K> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:jdk8u-jdk    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<? super K> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceKeysToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p.key));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceKeysToLongTask<K,V>
                t = (MapReduceKeysToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:jdk8u-jdk    文件:ConcurrentHashMap.java   
MapReduceValuesToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceValuesToLongTask<K,V> nextRight,
     ToLongFunction<? super V> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:jdk8u-jdk    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<? super V> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceValuesToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p.val));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceValuesToLongTask<K,V>
                t = (MapReduceValuesToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:jdk8u-jdk    文件:ConcurrentHashMap.java   
MapReduceEntriesToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceEntriesToLongTask<K,V> nextRight,
     ToLongFunction<Map.Entry<K,V>> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:jdk8u-jdk    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<Map.Entry<K,V>> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceEntriesToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceEntriesToLongTask<K,V>
                t = (MapReduceEntriesToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:jdk8u-jdk    文件:BasicTest.java   
public void testLongComparator() {
    Thing[] things = new Thing[longValues.length];
    for (int i=0; i<longValues.length; i++)
        things[i] = new Thing(0, longValues[i], 0.0, null);
    Comparator<Thing> comp = Comparator.comparingLong(new ToLongFunction<Thing>() {
        @Override
        public long applyAsLong(Thing thing) {
            return thing.getLongField();
        }
    });

    assertComparisons(things, comp, comparisons);
}
项目:openjdk-jdk10    文件:ConcurrentHashMap.java   
MapReduceKeysToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceKeysToLongTask<K,V> nextRight,
     ToLongFunction<? super K> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:openjdk-jdk10    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<? super K> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceKeysToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p.key));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceKeysToLongTask<K,V>
                t = (MapReduceKeysToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:openjdk-jdk10    文件:ConcurrentHashMap.java   
MapReduceValuesToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceValuesToLongTask<K,V> nextRight,
     ToLongFunction<? super V> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}
项目:openjdk-jdk10    文件:ConcurrentHashMap.java   
public final void compute() {
    final ToLongFunction<? super V> transformer;
    final LongBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        long r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceValuesToLongTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsLong(r, transformer.applyAsLong(p.val));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceValuesToLongTask<K,V>
                t = (MapReduceValuesToLongTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsLong(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
项目:openjdk-jdk10    文件:ConcurrentHashMap.java   
MapReduceEntriesToLongTask
    (BulkTask<K,V,?> p, int b, int i, int f, Node<K,V>[] t,
     MapReduceEntriesToLongTask<K,V> nextRight,
     ToLongFunction<Map.Entry<K,V>> transformer,
     long basis,
     LongBinaryOperator reducer) {
    super(p, b, i, f, t); this.nextRight = nextRight;
    this.transformer = transformer;
    this.basis = basis; this.reducer = reducer;
}