• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IntStreamEx类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setupStereoRenderTargets

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
private boolean setupStereoRenderTargets(GL4 gl4) {
    if (hmd == null) {
        return false;
    }
    IntBuffer width = GLBuffers.newDirectIntBuffer(1), height = GLBuffers.newDirectIntBuffer(1);

    hmd.GetRecommendedRenderTargetSize.apply(width, height);
    renderSize.set(width.get(0), height.get(0));

    IntStreamEx.range(VR.EVREye.Max).forEach(eye -> eyeDesc[eye] = new FramebufferDesc(gl4, renderSize));

    BufferUtils.destroyDirectBuffer(width);
    BufferUtils.destroyDirectBuffer(height);

    return true;
}
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:17,代码来源:Application.java


示例2: dispose

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Override
public void dispose(GLAutoDrawable drawable) {

    if (hmd != null) {
        VR.VR_Shutdown();
        hmd = null;
    }

    GL4 gl4 = drawable.getGL().getGL4();

    modelsRender.dispose(gl4);
    scene.dispose(gl4);
    axisLineControllers.dispose(gl4);
    distortion.dispose(gl4);

    IntStreamEx.range(VR.EVREye.Max).forEach(eye -> eyeDesc[eye].dispose(gl4));

    BufferUtils.destroyDirectBuffer(clearColor);
    BufferUtils.destroyDirectBuffer(clearDepth);
    BufferUtils.destroyDirectBuffer(errorBuffer);
    BufferUtils.destroyDirectBuffer(matBuffer);

    System.exit(0);
}
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:25,代码来源:Application.java


示例3: setupRenderModels

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
/**
 * Create/destroy GL Render Models.
 *
 * @param gl4
 * @param hmd
 */
public void setupRenderModels(GL4 gl4, IVRSystem hmd) {

    IntStreamEx.range(trackedDeviceToRenderModel.length).forEach(i -> trackedDeviceToRenderModel[i] = null);

    if (hmd == null) {
        return;
    }

    for (int trackedDevice = VR.k_unTrackedDeviceIndex_Hmd + 1; trackedDevice < VR.k_unMaxTrackedDeviceCount;
            trackedDevice++) {

        if (hmd.IsTrackedDeviceConnected.apply(trackedDevice) == 0) {
            continue;
        }
        setupRenderModelForTrackedDevice(gl4, trackedDevice, hmd);
    }
}
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:24,代码来源:ModelsRender.java


示例4: testSumming

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testSumming() {
    assertEquals(3725, (int) IntStreamEx.range(100).atLeast(50).collect(IntCollector.summing()));
    assertEquals(3725, (int) IntStreamEx.range(100).parallel().atLeast(50).collect(IntCollector.summing()));

    withRandom(r -> {
        int[] input = IntStreamEx.of(r, 10000, 1, 1000).toArray();
        Map<Boolean, Integer> expected = IntStream.of(input).boxed().collect(
            Collectors.partitioningBy(i -> i % 2 == 0, Collectors.summingInt(Integer::intValue)));
        Map<Boolean, Integer> sumEvenOdd = IntStreamEx.of(input).collect(
            IntCollector.partitioningBy(i -> i % 2 == 0, IntCollector.summing()));
        assertEquals(expected, sumEvenOdd);
        sumEvenOdd = IntStreamEx.of(input).parallel().collect(
            IntCollector.partitioningBy(i -> i % 2 == 0, IntCollector.summing()));
        assertEquals(expected, sumEvenOdd);
    });
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:18,代码来源:IntCollectorTest.java


示例5: testSummarizing

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testSummarizing() {
    withRandom(r -> {
        int[] data = IntStreamEx.of(r, 1000, 1, Integer.MAX_VALUE).toArray();
        IntSummaryStatistics expected = IntStream.of(data).summaryStatistics();
        IntSummaryStatistics statistics = IntStreamEx.of(data).collect(IntCollector.summarizing());
        assertEquals(expected.getCount(), statistics.getCount());
        assertEquals(expected.getSum(), statistics.getSum());
        assertEquals(expected.getMax(), statistics.getMax());
        assertEquals(expected.getMin(), statistics.getMin());
        statistics = IntStreamEx.of(data).parallel().collect(IntCollector.summarizing());
        assertEquals(expected.getCount(), statistics.getCount());
        assertEquals(expected.getSum(), statistics.getSum());
        assertEquals(expected.getMax(), statistics.getMax());
        assertEquals(expected.getMin(), statistics.getMin());
    });
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:18,代码来源:IntCollectorTest.java


示例6: testSpliterator

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testSpliterator() {
    int limit = 10;
    Supplier<List<Integer>> s = ArrayList::new;
    BiConsumer<List<Integer>, Integer> a = (acc, t) -> {
        if (acc.size() < limit)
            acc.add(t);
    };
    BinaryOperator<List<Integer>> c = (a1, a2) -> {
        a2.forEach(t -> a.accept(a1, t));
        return a1;
    };
    Predicate<List<Integer>> p = acc -> acc.size() >= limit;
    List<Integer> input = IntStreamEx.range(30).boxed().toList();
    List<Integer> expected = IntStreamEx.range(limit).boxed().toList();
    checkSpliterator("head-short-circuit", Collections.singletonList(expected),
        () -> new OrderedCancellableSpliterator<>(input.spliterator(), s, a, c, p));
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:19,代码来源:OrderedCancellableSpliteratorTest.java


示例7: ranges

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@operator (
		value = "range",
		content_type = IType.INT,
		category = { IOperatorCategory.CONTAINER },
		can_be_const = true)
@doc (
		value = "Allows to build a list of int representing all contiguous values from the first to the second argument, using the step represented by the third argument. The range can be increasing or decreasing. Passing the same value for both will return a singleton list with this value. Passing a step of 0 will result in an exception. Attempting to build infinite ranges (e.g. end > start with a negative step) will similarly not be accepted and yield an exception")
public static IList range(final IScope scope, final Integer start, final Integer end, final Integer step) {
	if (step == 0)
		throw GamaRuntimeException.error("The step of a range should not be equal to 0", scope);
	if (start.equals(end))
		return GamaListFactory.createWithoutCasting(Types.INT, start);
	if (end > start) {
		if (step < 0) { throw GamaRuntimeException.error("Negative step would result in an infinite range",
				scope); }
	} else {
		if (step > 0) { throw GamaRuntimeException.error("Positive step would result in an infinite range",
				scope); }
	}
	return IntStreamEx.rangeClosed(start, end, step).boxed().toCollection(listOf(Types.INT));

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:Containers.java


示例8: mockProvider

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
private void mockProvider(final WebDriverProvider provider, final int duplicatesAmount,
                          final BeforeMethodListener listener) {
    final WebDriverProvider spyProvider = spy(provider);
    final WebDriver mockDriver = mock(ChromeDriver.class);
    doReturn(mockDriver).when(spyProvider).createDriver(any(), any());
    final List<WebDriverProvider> providers = duplicatesAmount > 1
            ? IntStreamEx.range(0, duplicatesAmount).mapToObj(i -> provider).toList()
            : singletonList(spyProvider);
    doReturn(providers).when(listener).getWebDriverProviders();
}
 
开发者ID:sskorol,项目名称:webdriver-supplier,代码行数:11,代码来源:ListenerTests.java


示例9: initTexture

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
private void initTexture(GL4 gl4, RenderModel_TextureMap_t diffuseTexture) {

        // create and populate the texture
        gl4.glGenTextures(1, textureName);
        gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));

        ByteBuffer buffer = GLBuffers.newDirectByteBuffer(diffuseTexture.dataSize());
        byte[] data = diffuseTexture.rubTextureMapData.getByteArray(0, diffuseTexture.dataSize());

        IntStreamEx.range(diffuseTexture.dataSize()).forEach(i -> buffer.put(i, data[i]));

        gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, diffuseTexture.unWidth, diffuseTexture.unHeight,
                0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

        // If this renders black ask McJohn what's wrong.
        gl4.glGenerateMipmap(GL_TEXTURE_2D);

        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

        FloatBuffer largest = GLBuffers.newDirectFloatBuffer(1);
        gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, largest);
        gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest.get(0));

        gl4.glBindTexture(GL_TEXTURE_2D, 0);

        BufferUtils.destroyDirectBuffer(buffer);
        BufferUtils.destroyDirectBuffer(largest);
    }
 
开发者ID:java-opengl-labs,项目名称:jogl-hello-vr,代码行数:32,代码来源:Model.java


示例10: testIntStreamEx

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testIntStreamEx() {
    IntStreamEx.range(0, 4).parallel(pool).forEach(this::checkThread);
    assertEquals(6, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).sum());
    assertEquals(3, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).max().getAsInt());
    assertEquals(0, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).min().getAsInt());
    assertEquals(1.5, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).average().getAsDouble(),
        0.000001);
    assertEquals(4, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).summaryStatistics().getCount());
    assertArrayEquals(new int[] { 1, 2, 3 }, IntStreamEx.range(0, 5).parallel(pool).peek(this::checkThread).skip(1)
            .limit(3).toArray());
    assertEquals(6, IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).reduce(Integer::sum).getAsInt());
    assertTrue(IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).has(1));
    assertTrue(IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).anyMatch(x -> x == 2));
    assertFalse(IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).allMatch(x -> x == 2));
    assertFalse(IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).noneMatch(x -> x == 2));
    assertEquals(6, IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).reduce(1, (a, b) -> a * b));
    assertEquals(2, IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).atLeast(2).count());
    assertEquals(2, IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).findAny(x -> x % 2 == 0)
            .getAsInt());
    assertEquals(2, IntStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).findFirst(x -> x % 2 == 0)
            .getAsInt());
    List<Integer> res = new ArrayList<>();
    IntStreamEx.of(1, 5, 10, Integer.MAX_VALUE).parallel(pool).peek(this::checkThread).map(x -> x * 2)
            .forEachOrdered(res::add);
    //noinspection NumericOverflow
    assertEquals(Arrays.asList(2, 10, 20, Integer.MAX_VALUE * 2), res);
    assertArrayEquals(new int[] { 1, 3, 6, 10 }, IntStreamEx.of(1, 2, 3, 4).parallel(pool).peek(this::checkThread)
            .scanLeft((a, b) -> {
                checkThread(b);
                return a + b;
            }));
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:34,代码来源:CustomPoolTest.java


示例11: testLongStreamEx

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testLongStreamEx() {
    LongStreamEx.range(0, 4).parallel(pool).forEach(this::checkThread);
    assertEquals(999999000000L, IntStreamEx.range(1000000).parallel(pool).peek(this::checkThread).asLongStream()
            .map(x -> x * 2).sum());
    assertEquals(6, LongStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).sum());
    assertEquals(3, LongStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).max().getAsLong());
    assertEquals(0, LongStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).min().getAsLong());
    assertEquals(1.5, LongStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).average().getAsDouble(),
        0.000001);
    assertEquals(4, LongStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).summaryStatistics().getCount());
    assertArrayEquals(new long[] { 1, 2, 3 }, LongStreamEx.range(0, 5).parallel(pool).peek(this::checkThread).skip(
        1).limit(3).toArray());
    assertEquals(6, LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).reduce(Long::sum).getAsLong());
    assertTrue(LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).has(1));
    assertTrue(LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).anyMatch(x -> x == 2));
    assertFalse(LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).allMatch(x -> x == 2));
    assertFalse(LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).noneMatch(x -> x == 2));
    assertEquals(6, LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).reduce(1, (a, b) -> a * b));
    assertEquals(2, LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).atLeast(2).count());
    assertEquals(2, LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).findAny(x -> x % 2 == 0)
            .getAsLong());
    assertEquals(2, LongStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).findFirst(x -> x % 2 == 0)
            .getAsLong());
    List<Long> res = new ArrayList<>();
    LongStreamEx.of(1, 5, 10, Integer.MAX_VALUE).parallel(pool).peek(this::checkThread).map(x -> x * 2)
            .forEachOrdered(res::add);
    assertEquals(Arrays.asList(2L, 10L, 20L, Integer.MAX_VALUE * 2L), res);
    assertArrayEquals(new long[] { 1, 3, 6, 10 }, LongStreamEx.of(1, 2, 3, 4).parallel(pool)
            .peek(this::checkThread).scanLeft((a, b) -> {
                checkThread(b);
                return a + b;
            }));
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:35,代码来源:CustomPoolTest.java


示例12: testDoubleStreamEx

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testDoubleStreamEx() {
    LongStreamEx.range(0, 4).asDoubleStream().parallel(pool).forEach(this::checkThread);
    assertEquals(6, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).asDoubleStream().sum(), 0);
    assertEquals(3, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).asDoubleStream().max()
            .getAsDouble(), 0);
    assertEquals(0, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).asDoubleStream().min()
            .getAsDouble(), 0);
    assertEquals(1.5, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).asDoubleStream().average()
            .getAsDouble(), 0.000001);
    assertEquals(4, IntStreamEx.range(0, 4).parallel(pool).peek(this::checkThread).asDoubleStream()
            .summaryStatistics().getCount());
    assertArrayEquals(new double[] { 1, 2, 3 }, IntStreamEx.range(0, 5).asDoubleStream().skip(1).limit(3).parallel(
        pool).peek(this::checkThread).toArray(), 0.0);
    assertEquals(6.0, DoubleStreamEx.of(1.0, 2.0, 3.0).parallel(pool).peek(this::checkThread).reduce(Double::sum)
            .getAsDouble(), 0.0);
    assertTrue(DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).anyMatch(x -> x == 2));
    assertFalse(DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).allMatch(x -> x == 2));
    assertFalse(DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).noneMatch(x -> x == 2));
    assertEquals(6.0, DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).reduce(1, (a, b) -> a * b),
        0.0);
    assertEquals(2, DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).atLeast(2.0).count());
    assertEquals(2.0, DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).findAny(x -> x % 2 == 0)
            .getAsDouble(), 0.0);
    assertEquals(2.0, DoubleStreamEx.of(1, 2, 3).parallel(pool).peek(this::checkThread).findFirst(x -> x % 2 == 0)
            .getAsDouble(), 0.0);
    List<Double> res = new ArrayList<>();
    DoubleStreamEx.of(1.0, 2.0, 3.5, 4.5).parallel(pool).peek(this::checkThread).map(x -> x * 2).forEachOrdered(
        res::add);
    assertEquals(Arrays.asList(2.0, 4.0, 7.0, 9.0), res);
    assertArrayEquals(new double[] { 1, 3, 6, 10 }, DoubleStreamEx.of(1, 2, 3, 4).parallel(pool).peek(
        this::checkThread).scanLeft((a, b) -> {
        checkThread(b);
        return a + b;
    }), 0.0);
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:37,代码来源:CustomPoolTest.java


示例13: testPairMap

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testPairMap() {
    BitSet bits = IntStreamEx.range(3, 199).toBitSet();
    IntStreamEx.range(200).parallel(pool).filter(i -> {
        checkThread(i);
        return i > 2;
    }).boxed().pairMap(SimpleEntry::new).forEach(p -> {
        checkThread(p);
        assertEquals(1, p.getValue() - p.getKey());
        assertTrue(p.getKey().toString(), bits.get(p.getKey()));
        bits.clear(p.getKey());
    });
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:14,代码来源:CustomPoolTest.java


示例14: testShortCircuit

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testShortCircuit() {
    AtomicInteger counter = new AtomicInteger(0);
    assertEquals(Optional.empty(), IntStreamEx.range(0, 10000).boxed().parallel(pool).peek(this::checkThread).peek(
        t -> counter.incrementAndGet()).collect(MoreCollectors.onlyOne()));
    assertTrue(counter.get() < 10000);
    counter.set(0);
    assertEquals(Optional.empty(), IntStreamEx.range(0, 10000).boxed().mapToEntry(x -> x).parallel(pool).peek(
        this::checkThread).peek(t -> counter.incrementAndGet()).collect(MoreCollectors.onlyOne()));
    assertTrue(counter.get() < 10000);
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:12,代码来源:CustomPoolTest.java


示例15: testJoining

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testJoining() {
    String expected = IntStream.range(0, 10000).asDoubleStream().mapToObj(String::valueOf).collect(
        Collectors.joining(", "));
    assertEquals(expected, IntStreamEx.range(10000).asDoubleStream().collect(DoubleCollector.joining(", ")));
    assertEquals(expected, IntStreamEx.range(10000).asDoubleStream().parallel().collect(
        DoubleCollector.joining(", ")));
    String expected2 = IntStreamEx.range(0, 1000).asDoubleStream().boxed().toList().toString();
    assertEquals(expected2, IntStreamEx.range(1000).asDoubleStream().collect(
        DoubleCollector.joining(", ", "[", "]")));
    assertEquals(expected2, IntStreamEx.range(1000).asDoubleStream().parallel().collect(
        DoubleCollector.joining(", ", "[", "]")));
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:14,代码来源:DoubleCollectorTest.java


示例16: testCounting

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testCounting() {
    assertEquals(5000L, (long) IntStreamEx.range(10000).asDoubleStream().atLeast(5000).collect(
        DoubleCollector.counting()));
    assertEquals(5000L, (long) IntStreamEx.range(10000).asDoubleStream().parallel().atLeast(5000).collect(
        DoubleCollector.counting()));
    assertEquals(5000, (int) IntStreamEx.range(10000).asDoubleStream().atLeast(5000).collect(
        DoubleCollector.countingInt()));
    assertEquals(5000, (int) IntStreamEx.range(10000).asDoubleStream().parallel().atLeast(5000).collect(
        DoubleCollector.countingInt()));
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:12,代码来源:DoubleCollectorTest.java


示例17: testMin

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testMin() {
    assertEquals(50, IntStreamEx.range(100).asDoubleStream().atLeast(50).collect(DoubleCollector.min())
            .getAsDouble(), 0.0);
    assertEquals(50, IntStreamEx.range(100).asDoubleStream().atLeast(50).collect(
        DoubleCollector.min().andThen(OptionalDouble::getAsDouble)), 0.0);
    assertFalse(IntStreamEx.range(100).asDoubleStream().atLeast(200).collect(DoubleCollector.min()).isPresent());
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:9,代码来源:DoubleCollectorTest.java


示例18: testMax

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testMax() {
    assertEquals(99, IntStreamEx.range(100).asDoubleStream().atLeast(50).collect(DoubleCollector.max())
            .getAsDouble(), 0.0);
    assertEquals(99, IntStreamEx.range(100).asDoubleStream().parallel().atLeast(50).collect(DoubleCollector.max())
            .getAsDouble(), 0.0);
    assertFalse(IntStreamEx.range(100).asDoubleStream().atLeast(200).collect(DoubleCollector.max()).isPresent());
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:9,代码来源:DoubleCollectorTest.java


示例19: testToArray

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testToArray() {
    assertArrayEquals(new double[] { 0, 1, 2, 3, 4 }, IntStreamEx.of(0, 1, 2, 3, 4).asDoubleStream().collect(
        DoubleCollector.toArray()), 0.0);
    assertArrayEquals(IntStreamEx.range(1000).asDoubleStream().toFloatArray(), IntStreamEx.range(1000).parallel()
            .asDoubleStream().collect(DoubleCollector.toFloatArray()), 0.0f);
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:8,代码来源:DoubleCollectorTest.java


示例20: testPartitioning

import one.util.streamex.IntStreamEx; //导入依赖的package包/类
@Test
public void testPartitioning() {
    double[] expectedEven = IntStream.range(0, 1000).asDoubleStream().map(i -> i * 2).toArray();
    double[] expectedOdd = IntStream.range(0, 1000).asDoubleStream().map(i -> i * 2 + 1).toArray();
    Map<Boolean, double[]> oddEven = IntStreamEx.range(2000).asDoubleStream().collect(
        DoubleCollector.partitioningBy(i -> i % 2 == 0));
    assertArrayEquals(expectedEven, oddEven.get(true), 0.0);
    assertArrayEquals(expectedOdd, oddEven.get(false), 0.0);
    oddEven = IntStreamEx.range(2000).asDoubleStream().parallel().collect(
        DoubleCollector.partitioningBy(i -> i % 2 == 0));
    assertArrayEquals(expectedEven, oddEven.get(true), 0.0);
    assertArrayEquals(expectedOdd, oddEven.get(false), 0.0);
}
 
开发者ID:amaembo,项目名称:streamex,代码行数:14,代码来源:DoubleCollectorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RangeBuilder类代码示例发布时间:2022-05-23
下一篇:
Java OnColorChangedListener类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap