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


Java Arrays.parallelSetAll方法代码示例

本文整理汇总了Java中java.util.Arrays.parallelSetAll方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.parallelSetAll方法的具体用法?Java Arrays.parallelSetAll怎么用?Java Arrays.parallelSetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Arrays的用法示例。


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

示例1: run2

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void run2() {
    int[] arr=new int[10000000];
    Random r=new Random();
    /**串行给数组中每一个元素都附上一个随机值*/
    Arrays.setAll(arr, (i)->r.nextInt());

    /**并行给数组中每一个元素都附上一个随机值*/
    Arrays. parallelSetAll (arr, (i)->r.nextInt());
}
 
开发者ID:zhangboqing,项目名称:multithread,代码行数:11,代码来源:Parallel_Sort.java

示例2: testSetAllString

import java.util.Arrays; //导入方法依赖的package包/类
@Test(dataProvider = "string")
public void testSetAllString(String name, int size, IntFunction<String> generator, String[] expected) {
    String[] result = new String[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(String[], IntFunction<String>) case " + name + " failed.");

    // ensure fresh array
    result = new String[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(String[], IntFunction<String>) case " + name + " failed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SetAllTest.java

示例3: testSetAllInt

import java.util.Arrays; //导入方法依赖的package包/类
@Test(dataProvider = "int")
public void testSetAllInt(String name, int size, IntUnaryOperator generator, int[] expected) {
    int[] result = new int[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(int[], IntUnaryOperator) case " + name + " failed.");

    // ensure fresh array
    result = new int[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(int[], IntUnaryOperator) case " + name + " failed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SetAllTest.java

示例4: testSetAllLong

import java.util.Arrays; //导入方法依赖的package包/类
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SetAllTest.java

示例5: testSetAllDouble

import java.util.Arrays; //导入方法依赖的package包/类
@Test(dataProvider = "double")
public void testSetAllDouble(String name, int size, IntToDoubleFunction generator, double[] expected) {
    double[] result = new double[size];
    Arrays.setAll(result, generator);
    assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed.");

    // ensure fresh array
    result = new double[size];
    Arrays.parallelSetAll(result, generator);
    assertDoubleArrayEquals(result, expected, 0.05, "setAll(double[], IntToDoubleFunction) case " + name + " failed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SetAllTest.java

示例6: setHeader

import java.util.Arrays; //导入方法依赖的package包/类
public static void setHeader(String[] header) throws IllegalAccessException {

        if (CardHolder.header != null) {
            throw new IllegalAccessException("CardHolder.header can only be set once and never modified.");
        }

        Arrays.parallelSetAll(header, (i) -> header[ i ].trim());
        CardHolder.header = header;
    }
 
开发者ID:sharptopco,项目名称:cloudcard-csv-importer,代码行数:10,代码来源:CardHolder.java

示例7: parseInputString

import java.util.Arrays; //导入方法依赖的package包/类
public void parseInputString() {

        fieldValues = inputString.split(delimiter);
        Arrays.parallelSetAll(fieldValues, (i) -> fieldValues[ i ].trim());

        email = fieldValues[ EMAIL_INDEX ];
        id = fieldValues[ ID_INDEX ];
    }
 
开发者ID:sharptopco,项目名称:cloudcard-csv-importer,代码行数:9,代码来源:CardHolder.java

示例8: parallelInitialize

import java.util.Arrays; //导入方法依赖的package包/类
public static double[] parallelInitialize(int size) {
    double[] values = new double[size];
    Arrays.parallelSetAll(values, i -> i);
    return values;
}
 
开发者ID:jinyi233,项目名称:https-github.com-RichardWarburton-java-8-Lambdas-exercises,代码行数:6,代码来源:ArrayExamples.java


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