use of java.util.stream.IntStream in project systemml by apache.
the class DenseBlockLDRB method reset.
@SuppressWarnings("resource")
private void reset(int rlen, int clen, int blen, double v) {
long llen = (long) rlen * clen;
int numPart = (int) Math.ceil((double) rlen / blen);
if (this.blen == blen && llen < capacity()) {
for (int i = 0; i < numPart; i++) {
int lrlen = (int) (Math.min((i + 1) * blen, rlen) - i * blen);
Arrays.fill(data[i], 0, lrlen * clen, v);
}
} else {
data = new double[numPart][];
IntStream range = PARALLEL_ALLOC ? IntStream.range(0, numPart).parallel() : IntStream.range(0, numPart);
range.forEach(i -> data[i] = allocArray(i, rlen, clen, blen, v));
}
this.rlen = rlen;
this.clen = clen;
this.blen = blen;
}
use of java.util.stream.IntStream in project junit5 by junit-team.
the class CollectionUtilsTests method toStreamWithIntStream.
@SuppressWarnings("unchecked")
@Test
void toStreamWithIntStream() {
IntStream input = IntStream.of(23, 42);
Stream<Integer> result = (Stream<Integer>) CollectionUtils.toStream(input);
assertThat(result).containsExactly(23, 42);
}
use of java.util.stream.IntStream in project data-prep by Talend.
the class PreparationService method extractActionsAfterStep.
/**
* Extract all actions after a provided step
*
* @param stepsIds The steps list
* @param afterStep The (excluded) step id where to start the extraction
* @return The actions after 'afterStep' to the end of the list
*/
private List<AppendStep> extractActionsAfterStep(final List<String> stepsIds, final String afterStep) {
final int stepIndex = stepsIds.indexOf(afterStep);
if (stepIndex == -1) {
return emptyList();
}
final List<Step> steps;
try (IntStream range = IntStream.range(stepIndex, stepsIds.size())) {
steps = range.mapToObj(index -> getStep(stepsIds.get(index))).collect(toList());
}
final List<List<Action>> stepActions = steps.stream().map(this::getActions).collect(toList());
try (IntStream filteredActions = IntStream.range(1, steps.size())) {
return filteredActions.mapToObj(index -> {
final List<Action> previous = stepActions.get(index - 1);
final List<Action> current = stepActions.get(index);
final Step step = steps.get(index);
final AppendStep appendStep = new AppendStep();
appendStep.setDiff(step.getDiff());
appendStep.setActions(current.subList(previous.size(), current.size()));
return appendStep;
}).collect(toList());
}
}
use of java.util.stream.IntStream in project RoaringBitmap by RoaringBitmap.
the class RandomisedTestData method randomBitmap.
public static RoaringBitmap randomBitmap(int maxKeys) {
int[] keys = createSorted16BitInts(ThreadLocalRandom.current().nextInt(1, maxKeys));
double rleLimit = ThreadLocalRandom.current().nextDouble();
double denseLimit = ThreadLocalRandom.current().nextDouble(rleLimit, 1D);
OrderedWriter writer = new OrderedWriter();
IntStream.of(keys).forEach(key -> {
double choice = ThreadLocalRandom.current().nextDouble();
final IntStream stream;
if (choice < rleLimit) {
stream = rleRegion();
} else if (choice < denseLimit) {
stream = denseRegion();
} else {
stream = sparseRegion();
}
stream.map(i -> (key << 16) | i).forEach(writer::add);
});
writer.flush();
return writer.getUnderlying();
}
use of java.util.stream.IntStream in project RecordManager2 by moravianlibrary.
the class PublishDateMarcFunctions method range.
private List<Integer> range(int from, int to) {
IntStream stream = IntStream.rangeClosed(from, to);
List<Integer> result = new ArrayList<Integer>();
for (int year : stream.toArray()) {
result.add(year);
}
return result;
}
Aggregations