зеркало из
https://github.com/iharh/notes.git
synced 2025-10-30 05:06:05 +02:00
46 строки
2.0 KiB
Plaintext
46 строки
2.0 KiB
Plaintext
https://openjdk.org/jeps/461
|
|
|
|
2025
|
|
JavaTechie - Java Stream Gatherers Explained | The Next Evolution of Streams 0:00 of 28:00
|
|
https://www.youtube.com/watch?v=If6wFkY8ux4
|
|
JavaPro - Stream Gatherers | Karl Heinz Marbaise (EN) 0:00 of 45:04
|
|
https://www.youtube.com/watch?v=booidFJavSg
|
|
Jetbrains - Jose Paumard - Gatherers: The API Your Stream Was Missing of 1:10:31
|
|
https://www.youtube.com/watch?v=oVdWfU_IObY
|
|
https://gist.github.com/JosePaumard/c4379c9c53bbe98f1a60b2a25fc82d61
|
|
https://www.slideshare.net/jpaumard
|
|
https://www.slideshare.net/jpaumard/presentations
|
|
...
|
|
https://www.youtube.com/watch?v=jqUhObgDd5Q&list=PLxmvVTBGyuudYfIKthv2haNPneL9Upbgc&index=1
|
|
2024
|
|
IntelliJIdea - JEP Explained. JEP 473: Stream Gatherers 0:00 of 1:10:48
|
|
https://www.youtube.com/watch?v=m7PW6fMCrmg
|
|
CodeWiz - Stream Gatherers 0:00 of 16:56
|
|
https://www.youtube.com/watch?v=qBcuOCzvS3Y
|
|
public static <T> Gatherer<T, List<T>, List<T>> getFixedWindowGatherer(int limit) {
|
|
Supplier<List<T>> initializer = ArrayList::new;
|
|
Gatherer.Integrator<List<T>, T, List<T>> integrator = (state, element, downstream) -> {
|
|
state.add.element(element);
|
|
if (state.size() == limit) {
|
|
var group = List.copyOf(state);
|
|
downstream.push(group);
|
|
state.clear();
|
|
}
|
|
return true; // can consume more
|
|
};
|
|
BiConsumer<List<T>, Gatherer.Downstream<? super List<T>>> finisher = (state, downstream) -> {
|
|
if (!state.isEmpty()) {
|
|
downstream.push(List.copyOf(state));
|
|
}
|
|
};
|
|
return Gatherer.ofSequential(initializer, integrator, finisher);
|
|
}
|
|
|
|
List<List<...>> employeePairList = employees.stream()
|
|
.filter(...)
|
|
.map(Employee::name)
|
|
.gather(getFixedWindowGatherer(2))
|
|
.toList(); // [[Alice, Mary], [John, Ramesh], [Jen]]
|
|
|
|
// standard Gatherers: windowFixed, fold, scan, mapConcurrent, windowSliding
|