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


Java IntFunction类代码示例

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


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

示例1: opEvaluateParallel

import java.util.function.IntFunction; //导入依赖的package包/类
@Override
public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
                                         Spliterator<P_IN> spliterator,
                                         IntFunction<T[]> generator) {
    // If the input is already naturally sorted and this operation
    // naturally sorts then collect the output
    if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags()) && isNaturalSort) {
        return helper.evaluate(spliterator, false, generator);
    }
    else {
        // @@@ Weak two-pass parallel implementation; parallel collect, parallel sort
        T[] flattenedData = helper.evaluate(spliterator, true, generator).asArray(generator);
        Arrays.parallelSort(flattenedData, comparator);
        return Nodes.node(flattenedData);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:SortedOps.java

示例2: forColoredMaterial

import java.util.function.IntFunction; //导入依赖的package包/类
private static SchemeMapping forColoredMaterial(Material material) {
    final IntFunction<Item> func = value -> ItemStackBuilder.of(material).name("&f").data(value).build(null);

    Map<Integer, Item> map = ImmutableMap.<Integer, Item>builder()
            .put(0, func.apply(0))
            .put(1, func.apply(1))
            .put(2, func.apply(2))
            .put(3, func.apply(3))
            .put(4, func.apply(4))
            .put(5, func.apply(5))
            .put(6, func.apply(6))
            .put(7, func.apply(7))
            .put(8, func.apply(8))
            .put(9, func.apply(9))
            .put(10, func.apply(10))
            .put(11, func.apply(11))
            .put(12, func.apply(12))
            .put(13, func.apply(13))
            .put(14, func.apply(14))
            .put(15, func.apply(15))
            .build();

    return AbstractSchemeMapping.of(map);
}
 
开发者ID:lucko,项目名称:helper,代码行数:25,代码来源:StandardSchemeMappings.java

示例3: mapToObj

import java.util.function.IntFunction; //导入依赖的package包/类
@Override
public final <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Integer, U>(this, StreamShape.INT_VALUE,
                                                         StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedInt<U>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:IntPipeline.java

示例4: evaluateToArrayNode

import java.util.function.IntFunction; //导入依赖的package包/类
/**
 * Collect the elements output from the pipeline stage.
 *
 * @param generator the array generator to be used to create array instances
 * @return a flat array-backed Node that holds the collected output elements
 */
@SuppressWarnings("unchecked")
final Node<E_OUT> evaluateToArrayNode(IntFunction<E_OUT[]> generator) {
    if (linkedOrConsumed)
        throw new IllegalStateException(MSG_STREAM_LINKED);
    linkedOrConsumed = true;

    // If the last intermediate operation is stateful then
    // evaluate directly to avoid an extra collection step
    if (isParallel() && previousStage != null && opIsStateful()) {
        return opEvaluateParallel(previousStage, previousStage.sourceSpliterator(0), generator);
    }
    else {
        return evaluate(sourceSpliterator(0), true, generator);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:AbstractPipeline.java

示例5: testIntGet

import java.util.function.IntFunction; //导入依赖的package包/类
@Test(dataProvider = "intViewProvider")
public void testIntGet(String desc, IntFunction<ByteBuffer> fbb,
                       Function<ByteBuffer, IntBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    IntBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        int fromBytes = getIntFromBytes(bb, o + i * 4);
        int fromMethodView = bb.getInt(o + i * 4);
        assertValues(i, fromBytes, fromMethodView, bb);

        int fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        int v = getIntFromBytes(bb, o + i * 4);
        int a = bb.getInt();
        assertValues(i, v, a, bb);

        int b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例6: truncate

import java.util.function.IntFunction; //导入依赖的package包/类
@Override
default Node.OfInt truncate(long from, long to, IntFunction<Integer[]> generator) {
    if (from == 0 && to == count())
        return this;
    long size = to - from;
    Spliterator.OfInt spliterator = spliterator();
    Node.Builder.OfInt nodeBuilder = Nodes.intBuilder(size);
    nodeBuilder.begin(size);
    for (int i = 0; i < from && spliterator.tryAdvance((IntConsumer) e -> { }); i++) { }
    if (to == count()) {
        spliterator.forEachRemaining((IntConsumer) nodeBuilder);
    } else {
        for (int i = 0; i < size && spliterator.tryAdvance((IntConsumer) nodeBuilder); i++) { }
    }
    nodeBuilder.end();
    return nodeBuilder.build();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Node.java

示例7: testFloatGet

import java.util.function.IntFunction; //导入依赖的package包/类
@Test(dataProvider = "floatViewProvider")
public void testFloatGet(String desc, IntFunction<ByteBuffer> fbb,
                         Function<ByteBuffer, FloatBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    FloatBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        float fromBytes = getFloatFromBytes(bb, o + i * 4);
        float fromMethodView = bb.getFloat(o + i * 4);
        assertValues(i, fromBytes, fromMethodView, bb);

        float fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        float v = getFloatFromBytes(bb, o + i * 4);
        float a = bb.getFloat();
        assertValues(i, v, a, bb);

        float b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例8: opEvaluateParallel

import java.util.function.IntFunction; //导入依赖的package包/类
@Override
public <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
                                               Spliterator<P_IN> spliterator,
                                               IntFunction<Integer[]> generator) {
    if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags())) {
        return helper.evaluate(spliterator, false, generator);
    }
    else {
        Node.OfInt n = (Node.OfInt) helper.evaluate(spliterator, true, generator);

        int[] content = n.asPrimitiveArray();
        Arrays.parallelSort(content);

        return Nodes.node(content);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SortedOps.java

示例9: setBlockBiomeTint

import java.util.function.IntFunction; //导入依赖的package包/类
@Override
public void setBlockBiomeTint(Block block, IntFunction<BlockTint> tintTypeForSubtype)
{
    if (!(block instanceof CSBlock))
        return;

    BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
    CSBlock csBlock = (CSBlock) block;
    blockColors.registerBlockColorHandler(
            (state, worldIn, pos, tintIndex) -> {
                if (worldIn == null || pos == null)
                    return ColorizerFoliage.getFoliageColorBasic();

                return tintTypeForSubtype.apply(csBlock.getSubtype(state)).getMultiplier(worldIn, pos);

                /*if (tintType == BiomeTintType.FOLIAGE)
                    return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
                if (tintType == BiomeTintType.GRASS)
                    return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
                if (tintType == BiomeTintType.WATER)
                    return BiomeColorHelper.getWaterColorAtPos(worldIn, pos);

                return -1;*/
            }, block);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:26,代码来源:ClientProxy.java

示例10: writeLineSeparator

import java.util.function.IntFunction; //导入依赖的package包/类
static void writeLineSeparator(Path p,
                               IntFunction<LineSeparator> lineSeparatorGenerator,
                               int lines, Charset cs) throws IOException {
    BufferedWriter bw = Files.newBufferedWriter(p, cs, StandardOpenOption.APPEND);
    bw.write(lineSeparatorGenerator.apply(lines - 1).value);
    bw.flush();
    bw.close();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:StreamLinesTest.java

示例11: TakeWhileTask

import java.util.function.IntFunction; //导入依赖的package包/类
TakeWhileTask(AbstractPipeline<P_OUT, P_OUT, ?> op,
              PipelineHelper<P_OUT> helper,
              Spliterator<P_IN> spliterator,
              IntFunction<P_OUT[]> generator) {
    super(helper, spliterator);
    this.op = op;
    this.generator = generator;
    this.isOrdered = StreamOpFlag.ORDERED.isKnown(helper.getStreamAndOpFlags());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:WhileOps.java

示例12: create

import java.util.function.IntFunction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> T create(Map<Class<?>, IntFunction<?>> map, Class<T> clazz, int size)
{
    IntFunction<?> intFunction = map.get(clazz);
    if (intFunction != null)
    {
        return (T) intFunction.apply(size);
    }
    if ((! Modifier.isAbstract(clazz.getModifiers())) && (Map.class.isAssignableFrom(clazz) || Collection.class.isAssignableFrom(clazz)))
    {
        ConstructorInvoker<T> constructor = DioriteReflectionUtils.getConstructor(clazz, false);
        if (constructor != null)
        {
            constructor.ensureAccessible();
            IntFunction<T> creator = constructor::invokeWith;
            map.put(clazz, creator);
            return creator.apply(size);
        }
    }
    for (Entry<Class<?>, IntFunction<?>> entry : map.entrySet())
    {
        if (clazz.isAssignableFrom(entry.getKey()))
        {
            IntFunction<?> function = entry.getValue();
            map.put(clazz, function);
            return (T) function.apply(size);
        }
    }
    throw new YAMLException("Can't create collection: " + clazz);
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:31,代码来源:YamlCollectionCreator.java

示例13: ArrayNode

import java.util.function.IntFunction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
ArrayNode(long size, IntFunction<T[]> generator) {
    if (size >= MAX_ARRAY_SIZE)
        throw new IllegalArgumentException(BAD_SIZE);
    this.array = generator.apply((int) size);
    this.curSize = 0;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Nodes.java

示例14: mapToArray

import java.util.function.IntFunction; //导入依赖的package包/类
public static <T, R> R[] mapToArray(Collection<T> inputs, Function<? super T, ? extends R> mapper, IntFunction<R[]> arrayGenerator) {
    R[] result = arrayGenerator.apply(inputs.size());
    int idx = 0;
    for (T t : inputs) {
        result[idx++] = mapper.apply(t);
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CollectionsUtil.java

示例15: readArray

import java.util.function.IntFunction; //导入依赖的package包/类
public <T> T[] readArray(Writeable.Reader<T> reader, IntFunction<T[]> arraySupplier) throws IOException {
    int length = readArraySize();
    T[] values = arraySupplier.apply(length);
    for (int i = 0; i < length; i++) {
        values[i] = reader.read(this);
    }
    return values;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:StreamInput.java


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