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


Java IntBinaryOperator類代碼示例

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


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

示例1: testIntMethods

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
public void testIntMethods() {
    BinaryOperator<Integer> sum1 = Integer::sum;
    IntBinaryOperator sum2 = Integer::sum;
    BinaryOperator<Integer> max1 = Integer::max;
    IntBinaryOperator max2 = Integer::max;
    BinaryOperator<Integer> min1 = Integer::min;
    IntBinaryOperator min2 = Integer::min;
    Comparator<Integer> cmp = Integer::compare;

    int[] numbers = { -1, 0, 1, 100, Integer.MAX_VALUE, Integer.MIN_VALUE };
    for (int i : numbers) {
        for (int j : numbers) {
            assertEquals(i+j, (int) sum1.apply(i, j));
            assertEquals(i+j, sum2.applyAsInt(i, j));
            assertEquals(Math.max(i,j), (int) max1.apply(i, j));
            assertEquals(Math.max(i,j), max2.applyAsInt(i, j));
            assertEquals(Math.min(i,j), (int) min1.apply(i, j));
            assertEquals(Math.min(i,j), min2.applyAsInt(i, j));
            assertEquals(((Integer) i).compareTo(j), cmp.compare(i, j));
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:PrimitiveSumMinMaxTest.java

示例2: compute

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
public final void compute() {
    final ToIntBiFunction<? super K, ? super V> transformer;
    final IntBinaryOperator reducer;
    if ((transformer = this.transformer) != null &&
        (reducer = this.reducer) != null) {
        int r = this.basis;
        for (int i = baseIndex, f, h; batch > 0 &&
                 (h = ((f = baseLimit) + i) >>> 1) > i;) {
            addToPendingCount(1);
            (rights = new MapReduceMappingsToIntTask<K,V>
             (this, batch >>>= 1, baseLimit = h, f, tab,
              rights, transformer, r, reducer)).fork();
        }
        for (Node<K,V> p; (p = advance()) != null; )
            r = reducer.applyAsInt(r, transformer.applyAsInt(p.key, p.val));
        result = r;
        CountedCompleter<?> c;
        for (c = firstComplete(); c != null; c = c.nextComplete()) {
            @SuppressWarnings("unchecked")
            MapReduceMappingsToIntTask<K,V>
                t = (MapReduceMappingsToIntTask<K,V>)c,
                s = t.rights;
            while (s != null) {
                t.result = reducer.applyAsInt(t.result, s.result);
                s = t.rights = s.nextRight;
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:ConcurrentHashMap.java

示例3: map

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
@NonNull
@Override
public MuVector4i map(@NonNull final Vector4i that, @NonNull final IntBinaryOperator operator) {
  this.x = operator.applyAsInt(this.x, that.x());
  this.y = operator.applyAsInt(this.y, that.y());
  this.z = operator.applyAsInt(this.z, that.z());
  this.w = operator.applyAsInt(this.w, that.w());
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:10,代碼來源:MuVector4i.java

示例4: map

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
@NonNull
@Override
public MuVector3i map(@NonNull final Vector3i that, @NonNull final IntBinaryOperator operator) {
  this.x = operator.applyAsInt(this.x, that.x());
  this.y = operator.applyAsInt(this.y, that.y());
  this.z = operator.applyAsInt(this.z, that.z());
  return this;
}
 
開發者ID:KyoriPowered,項目名稱:math,代碼行數:9,代碼來源:MuVector3i.java

示例5: map

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

示例6: traverseGrid

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
public int traverseGrid(IntBinaryOperator func) {
    AtomicInteger at = new AtomicInteger();
    traversalX.forEach(t_x -> {
        traversalY.forEach(t_y -> {
            at.addAndGet(func.applyAsInt(t_x, t_y));
        });
    });

    return at.get();
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:11,代碼來源:GridOperator.java

示例7: createEqOp

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
private static BiFunction<Integer, Integer, Pair<Integer, Integer[]>> createEqOp(IntBinaryOperator simpleOp)
{
    return (x, y) ->
    {
        int res = simpleOp.applyAsInt(x, y);
        return Pair.of(x, new Integer[]{y, res});
    };
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:9,代碼來源:EquationOperations.java

示例8: getAndAccumulate

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
public final int getAndAccumulate(int i, int x, IntBinaryOperator accumulatorFunction) {
    long offset = checkedByteOffset(i);
    int prev, next;
    do {
        prev = getRaw(offset);
        next = accumulatorFunction.applyAsInt(prev, x);
    } while (!compareAndSetRaw(offset, prev, next));
    return prev;
}
 
開發者ID:catap,項目名稱:atomic,代碼行數:10,代碼來源:AtomicIntegerArray.java

示例9: accumulateAndGet

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
public final int accumulateAndGet(int i, int x, IntBinaryOperator accumulatorFunction) {
    long offset = checkedByteOffset(i);
    int prev, next;
    do {
        prev = getRaw(offset);
        next = accumulatorFunction.applyAsInt(prev, x);
    } while (!compareAndSetRaw(offset, prev, next));
    return next;
}
 
開發者ID:catap,項目名稱:atomic,代碼行數:10,代碼來源:AtomicIntegerArray.java

示例10: getAndAccumulate

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

示例11: accumulateAndGet

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

示例12: bitStringArithmeticAlignedWords

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
private void bitStringArithmeticAlignedWords(IntBinaryOperator op, int sourceAddr, int destinationAddr, int length) {
    for (int i = 0; i < length; i++) {
        int src = bus.getWord(sourceAddr + i * Integer.BYTES);
        int dst = bus.getWord(destinationAddr + i * Integer.BYTES);
        bus.setWord(destinationAddr + i * Integer.BYTES, op.applyAsInt(src, dst));
    }
}
 
開發者ID:gilles-duboscq,項目名稱:jvb,代碼行數:8,代碼來源:CPU.java

示例13: makeInt

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

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

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

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

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

示例14: IntCumulateTask

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
/** Root task constructor */
public IntCumulateTask(IntCumulateTask parent,
                       IntBinaryOperator function,
                       int[] array, int lo, int hi) {
    super(parent);
    this.function = function; this.array = array;
    this.lo = this.origin = lo; this.hi = this.fence = hi;
    int p;
    this.threshold =
            (p = (hi - lo) / (ForkJoinPool.getCommonPoolParallelism() << 3))
            <= MIN_PARTITION ? MIN_PARTITION : p;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:ArrayPrefixHelpers.java

示例15: getBinaryOperator

import java.util.function.IntBinaryOperator; //導入依賴的package包/類
private static BinaryOperator<Vec3I> getBinaryOperator(IntBinaryOperator op) {
  return (a, b) -> {
    int x = op.applyAsInt(a.x, b.x);
    int y = op.applyAsInt(a.y, b.y);
    int z = op.applyAsInt(a.z, b.z);
    return new Vec3I(x, y, z);
  };
}
 
開發者ID:Energyxxer,項目名稱:Vanilla-Injection,代碼行數:9,代碼來源:Vec3I.java


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