Skip to content

Commit

Permalink
SampleSet
Browse files Browse the repository at this point in the history
  • Loading branch information
apete committed Oct 6, 2024
1 parent 2013cde commit 0d33119
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 174 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Added / Changed / Deprecated / Fixed / Removed / Security

> Corresponds to changes in the `develop` branch since the last release
### Changed

#### org.ojalgo.random

- Refactored `SampleSet` (internally) to be better aligned with recent changes to other parts of the library. Primarily the class now uses `int` indices for all internal calculations. Also added a new `java.util.stream.Collector` implementation to simplify `SampleSet` creation from streams.

## [55.0.0] – 2024-09-28

### Changed
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/org/ojalgo/array/NumberList.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ public NumberList<N> make() {
}

public static <N extends Comparable<N>> Collector<N, NumberList<N>, NumberList<N>> collector(final DenseArray.Factory<N> arrayFactory) {
final Supplier<NumberList<N>> tmpSupplier = () -> NumberList.factory(arrayFactory).make();
final BiConsumer<NumberList<N>, N> tmpAccumulator = NumberList::add;
final BinaryOperator<NumberList<N>> tmpCombiner = (part1, part2) -> {

Supplier<NumberList<N>> supplier = () -> NumberList.factory(arrayFactory).make();
BiConsumer<NumberList<N>, N> accumulator = NumberList::add;
BinaryOperator<NumberList<N>> combiner = (part1, part2) -> {
part1.addAll(part2);
return part1;
};
final Function<NumberList<N>, NumberList<N>> tmpIdentity = Function.identity();
return Collector.of(tmpSupplier, tmpAccumulator, tmpCombiner, tmpIdentity, Collector.Characteristics.IDENTITY_FINISH);
Function<NumberList<N>, NumberList<N>> finisher = Function.identity();

return Collector.of(supplier, accumulator, combiner, finisher, Collector.Characteristics.IDENTITY_FINISH);
}

public static <N extends Comparable<N>> ListFactory<N> factory(final DenseArray.Factory<N> arrayFactory) {
Expand Down
Loading

0 comments on commit 0d33119

Please sign in to comment.