Этот коммит содержится в:
Ihar Hancharenka 2025-01-04 21:43:10 +03:00
родитель 5ea4e00e7e
Коммит 9050d85aeb
2 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -1 +1,31 @@
https://openjdk.org/jeps/461 https://openjdk.org/jeps/461
2024
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

Просмотреть файл

@ -1,3 +1,7 @@
2024
Devoxx - jbang - Unleash the power of Java by Max Rydahl Andersen of 31:34
https://www.youtube.com/watch?v=cpKwBbz1sf0
! catalog, edit, junit, ?profile
2021 2021
Anderson - JBang: let's make Java fun to use again! 44:00 of 1:18:02 Anderson - JBang: let's make Java fun to use again! 44:00 of 1:18:02
https://www.youtube.com/watch?v=5Gf1Dswl-gs https://www.youtube.com/watch?v=5Gf1Dswl-gs