本文整理匯總了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());
}