本文整理汇总了Java中java.util.stream.IntStream.range方法的典型用法代码示例。如果您正苦于以下问题:Java IntStream.range方法的具体用法?Java IntStream.range怎么用?Java IntStream.range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.stream.IntStream
的用法示例。
在下文中一共展示了IntStream.range方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: produceCases
import java.util.stream.IntStream; //导入方法依赖的package包/类
@DataProvider(name = "cases")
public static Object[][] produceCases() {
return new Object[][] {
{ "none", IntStream.empty() },
{ "index 0", IntStream.of(0) },
{ "index 255", IntStream.of(255) },
{ "index 0 and 255", IntStream.of(0, 255) },
{ "index Integer.MAX_VALUE", IntStream.of(Integer.MAX_VALUE) },
{ "index Integer.MAX_VALUE - 1", IntStream.of(Integer.MAX_VALUE - 1) },
{ "index 0 and Integer.MAX_VALUE", IntStream.of(0, Integer.MAX_VALUE) },
{ "every bit", IntStream.range(0, 255) },
{ "step 2", IntStream.range(0, 255).map(f -> f * 2) },
{ "step 3", IntStream.range(0, 255).map(f -> f * 3) },
{ "step 5", IntStream.range(0, 255).map(f -> f * 5) },
{ "step 7", IntStream.range(0, 255).map(f -> f * 7) },
{ "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) },
{ "25 fibs", IntStream.generate(new Fibs()).limit(25) }
};
}
示例2: bepaalRegelnummers
import java.util.stream.IntStream; //导入方法依赖的package包/类
private List<Integer> bepaalRegelnummers(final int totaalAantalRegels) {
final IntStream regelsInSteekproef;
if (totaalAantalRegels <= maxPersonenInSteekproef()) {
//statische steekproef
regelsInSteekproef = IntStream.range(0, totaalAantalRegels);
} else {
//random steekproef, dubbele personen is geen probleem
final Random random = new Random();
regelsInSteekproef = IntStream.generate(() -> random.nextInt(totaalAantalRegels)).limit(maxPersonenInSteekproef()).sorted();
}
return regelsInSteekproef.boxed().collect(Collectors.toList());
}
示例3: testXxxStream
import java.util.stream.IntStream; //导入方法依赖的package包/类
/**
* jdk提供的其他创建流的方式
*/
@Test
public void testXxxStream() {
IntStream intStream = IntStream.range(1, 10);
DoubleStream doubleStream = DoubleStream.of(10.2, 20.1);
LongStream longStream = LongStream.range(1, 100);
}
示例4: apply
import java.util.stream.IntStream; //导入方法依赖的package包/类
/**
* Returns a new list which is the result of applying the mapping function to values of the input list
* @param list the input list on which to apply the mapping function to all elements
* @param parallel true if parallel mapping should be used
* @param listMapper the list mapper function to apply to all values in input list
* @param <I> the input list type
* @param <O> the output list type
* @return the output list
*/
public static <I,O> List<O> apply(List<I> list, boolean parallel, ListMapper<I,O> listMapper) {
final int size = list.size();
final List<O> result = createList(list);
IntStream.range(0, size).forEach(i -> result.add(null));
final IntStream indexes = parallel ? IntStream.range(0, size).parallel() : IntStream.range(0, size);
indexes.forEach(index -> {
final I source = list.get(index);
final O target = listMapper.apply(index, source);
result.set(index, target);
});
return result;
}
示例5: head
import java.util.stream.IntStream; //导入方法依赖的package包/类
@Override()
public final DataFrame<R, C> head(int count) {
final IntStream indexes = IntStream.range(0, Math.min(count, rowCount()));
final Array<R> keys = indexes.mapToObj(i -> rows().key(i)).collect(ArrayUtils.toArray());
final Index<R> newRowAxis = rowKeys().filter(keys);
final Index<C> newColAxis = colKeys();
final XDataFrameContent<R,C> newContents = data.filter(newRowAxis, newColAxis);
return new XDataFrame<>(newContents, parallel);
}
示例6: tail
import java.util.stream.IntStream; //导入方法依赖的package包/类
@Override()
public final DataFrame<R, C> tail(int count) {
final IntStream indexes = IntStream.range(Math.max(0, rowCount() - count), rowCount());
final Array<R> keys = indexes.mapToObj(i -> rows().key(i)).collect(ArrayUtils.toArray());
final Index<R> newRowAxis = rowKeys().filter(keys);
final Index<C> newColAxis = colKeys();
final XDataFrameContent<R,C> newContents = data.filter(newRowAxis, newColAxis);
return new XDataFrame<>(newContents, parallel);
}
示例7: getBucketsStream
import java.util.stream.IntStream; //导入方法依赖的package包/类
private IntStream getBucketsStream(long offset, long length) {
final int startIndex = bucketFromOffset(offset);
final int endIndex = bucketFromOffset(offset + length - 1);
return IntStream.range(startIndex, endIndex + 1);
}
示例8: testSerialToParallel
import java.util.stream.IntStream; //导入方法依赖的package包/类
@Test
public void testSerialToParallel() {
IntStream range = IntStream.range(0, 100);
assertEquals(328350, SerialToParallel.sumOfSquares(range));
}
开发者ID:jinyi233,项目名称:https-github.com-RichardWarburton-java-8-Lambdas-exercises,代码行数:6,代码来源:SerialToParallelTest.java
示例9: indexes
import java.util.stream.IntStream; //导入方法依赖的package包/类
@Override()
public final IntStream indexes() {
return indexes != null ? indexes.stream().ints() : IntStream.range(0, size());
}
示例10: ordinals
import java.util.stream.IntStream; //导入方法依赖的package包/类
@Override
public final IntStream ordinals() {
return IntStream.range(0, axis.size());
}