當前位置: 首頁>>代碼示例>>Java>>正文


Java LongBinaryOperator.applyAsLong方法代碼示例

本文整理匯總了Java中java.util.function.LongBinaryOperator.applyAsLong方法的典型用法代碼示例。如果您正苦於以下問題:Java LongBinaryOperator.applyAsLong方法的具體用法?Java LongBinaryOperator.applyAsLong怎麽用?Java LongBinaryOperator.applyAsLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.function.LongBinaryOperator的用法示例。


在下文中一共展示了LongBinaryOperator.applyAsLong方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: map

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
@NonNull
@Override
public MuVector2l map(@NonNull final Vector2l that, @NonNull final LongBinaryOperator operator) {
  this.x = operator.applyAsLong(this.x, that.x());
  this.y = operator.applyAsLong(this.y, that.y());
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:8,代碼來源:MuVector2l.java

示例2: compute

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
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;
            }
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:30,代碼來源:ConcurrentHashMap.java

示例3: accumulateAndGet

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
public final long accumulateAndGet(long x, LongBinaryOperator accumulatorFunction) {
    long prev, next;
    do {
        prev = value;
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSet(prev, next));
    return next;
}
 
開發者ID:catap,項目名稱:atomic,代碼行數:9,代碼來源:AtomicLong.java

示例4: compute

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
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;
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:ConcurrentHashMap.java

示例5: makeLong

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Constructs a {@code TerminalOp} that implements a functional reduce on
 * {@code long} values.
 *
 * @param identity the identity for the combining function
 * @param operator the combining function
 * @return a {@code TerminalOp} implementing the reduction
 */
public static TerminalOp<Long, Long>
makeLong(long identity, LongBinaryOperator operator) {
    Objects.requireNonNull(operator);
    class ReducingSink
            implements AccumulatingSink<Long, Long, ReducingSink>, Sink.OfLong {
        private long state;

        @Override
        public void begin(long size) {
            state = identity;
        }

        @Override
        public void accept(long t) {
            state = operator.applyAsLong(state, t);
        }

        @Override
        public Long get() {
            return state;
        }

        @Override
        public void combine(ReducingSink other) {
            accept(other.state);
        }
    }
    return new ReduceOp<Long, Long, ReducingSink>(StreamShape.LONG_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:43,代碼來源:ReduceOps.java

示例6: accumulateAndGet

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates the current value with the results of
 * applying the given function to the current and given values,
 * returning the updated value. The function should be
 * side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function
 * is applied with the current value as its first argument,
 * and the given update as the second argument.
 *
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the updated value
 * @since 1.8
 */
public final long accumulateAndGet(long x,
                                   LongBinaryOperator accumulatorFunction) {
    long prev, next;
    do {
        prev = get();
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSet(prev, next));
    return next;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:AtomicLong.java

示例7: getAndAccumulate

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates (with memory effects as specified by {@link
 * VarHandle#compareAndSet}) the field of the given object managed
 * by this updater with the results of applying the given function
 * to the current and given values, returning the previous value.
 * The function should be side-effect-free, since it may be
 * re-applied when attempted updates fail due to contention among
 * threads.  The function is applied with the current value as its
 * first argument, and the given update as the second argument.
 *
 * @param obj An object whose field to get and set
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the previous value
 * @since 1.8
 */
public final long getAndAccumulate(T obj, long x,
                                   LongBinaryOperator accumulatorFunction) {
    long prev, next;
    do {
        prev = get(obj);
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSet(obj, prev, next));
    return prev;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:AtomicLongFieldUpdater.java

示例8: getAndAccumulate

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates the current value with the results of
 * applying the given function to the current and given values,
 * returning the previous value. The function should be
 * side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function
 * is applied with the current value as its first argument,
 * and the given update as the second argument.
 *
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the previous value
 * @since 1.8
 */
public final long getAndAccumulate(long x,
                                   LongBinaryOperator accumulatorFunction) {
    long prev, next;
    do {
        prev = get();
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSet(prev, next));
    return prev;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:AtomicLong.java

示例9: getAndAccumulate

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates (with memory effects as specified by {@link
 * VarHandle#compareAndSet}) the current value with the results of
 * applying the given function to the current and given values,
 * returning the previous value. The function should be
 * side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function is
 * applied with the current value as its first argument, and the
 * given update as the second argument.
 *
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the previous value
 * @since 1.8
 */
public final long getAndAccumulate(long x,
                                   LongBinaryOperator accumulatorFunction) {
    long prev = get(), next = 0L;
    for (boolean haveNext = false;;) {
        if (!haveNext)
            next = accumulatorFunction.applyAsLong(prev, x);
        if (weakCompareAndSetVolatile(prev, next))
            return prev;
        haveNext = (prev == (prev = get()));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:AtomicLong.java

示例10: getAndAccumulate

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates the field of the given object managed by this
 * updater with the results of applying the given function to the
 * current and given values, returning the previous value. The
 * function should be side-effect-free, since it may be re-applied
 * when attempted updates fail due to contention among threads.  The
 * function is applied with the current value as its first argument,
 * and the given update as the second argument.
 *
 * @param obj An object whose field to get and set
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the previous value
 * @since 1.8
 */
public final long getAndAccumulate(T obj, long x,
                                   LongBinaryOperator accumulatorFunction) {
    long prev, next;
    do {
        prev = get(obj);
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSet(obj, prev, next));
    return prev;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:AtomicLongFieldUpdater.java

示例11: getAndAccumulate

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates (with memory effects as specified by {@link
 * VarHandle#compareAndSet}) the element at index {@code i} with
 * the results of applying the given function to the current and
 * given values, returning the previous value. The function should
 * be side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function is
 * applied with the current value of the element at index {@code i}
 * as its first argument, and the given update as the second
 * argument.
 *
 * @param i the index
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the previous value
 * @since 1.8
 */
public final long getAndAccumulate(int i, long x,
                                  LongBinaryOperator accumulatorFunction) {
    long prev = get(i), next = 0L;
    for (boolean haveNext = false;;) {
        if (!haveNext)
            next = accumulatorFunction.applyAsLong(prev, x);
        if (weakCompareAndSetVolatile(i, prev, next))
            return prev;
        haveNext = (prev == (prev = get(i)));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:AtomicLongArray.java

示例12: accumulateAndGet

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates the element at index {@code i} with the
 * results of applying the given function to the current and
 * given values, returning the updated value. The function should
 * be side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function is
 * applied with the current value at index {@code i} as its first
 * argument, and the given update as the second argument.
 *
 * @param i the index
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the updated value
 * @since 1.8
 */
public final long accumulateAndGet(int i, long x,
                                  LongBinaryOperator accumulatorFunction) {
    long offset = checkedByteOffset(i);
    long prev, next;
    do {
        prev = getRaw(offset);
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSetRaw(offset, prev, next));
    return next;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:AtomicLongArray.java

示例13: accumulateAndGet

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates (with memory effects as specified by {@link
 * VarHandle#compareAndSet}) the element at index {@code i} with
 * the results of applying the given function to the current and
 * given values, returning the updated value. The function should
 * be side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function is
 * applied with the current value of the element at index {@code i}
 * as its first argument, and the given update as the second
 * argument.
 *
 * @param i the index
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the updated value
 * @since 1.8
 */
public final long accumulateAndGet(int i, long x,
                                  LongBinaryOperator accumulatorFunction) {
    long prev = get(i), next = 0L;
    for (boolean haveNext = false;;) {
        if (!haveNext)
            next = accumulatorFunction.applyAsLong(prev, x);
        if (weakCompareAndSetVolatile(i, prev, next))
            return next;
        haveNext = (prev == (prev = get(i)));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:AtomicLongArray.java

示例14: getAndAccumulate

import java.util.function.LongBinaryOperator; //導入方法依賴的package包/類
/**
 * Atomically updates the element at index {@code i} with the
 * results of applying the given function to the current and
 * given values, returning the previous value. The function should
 * be side-effect-free, since it may be re-applied when attempted
 * updates fail due to contention among threads.  The function is
 * applied with the current value at index {@code i} as its first
 * argument, and the given update as the second argument.
 *
 * @param i the index
 * @param x the update value
 * @param accumulatorFunction a side-effect-free function of two arguments
 * @return the previous value
 * @since 1.8
 */
public final long getAndAccumulate(int i, long x,
                                  LongBinaryOperator accumulatorFunction) {
    long offset = checkedByteOffset(i);
    long prev, next;
    do {
        prev = getRaw(offset);
        next = accumulatorFunction.applyAsLong(prev, x);
    } while (!compareAndSetRaw(offset, prev, next));
    return prev;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:AtomicLongArray.java


注:本文中的java.util.function.LongBinaryOperator.applyAsLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。