Giriş
Şu satırı dahil ederiz
Şu satırı dahil ederiz
import java.util.stream.Collectors;
Örnek Şöyle yaparız.
List<Event> getNearEventsConcurrent(int number, List<Event> events, String targetLocation) {
Map<Integer, Set<Event>> distanceEventsMap = events.stream().parallel().
collect(Collectors.groupingByConcurrent(
event -> evaluateLocationProximity(event.location(), targetLocation),
ConcurrentSkipListMap::new,
Collectors.toCollection(() -> new TreeSet<>(
Comparator.comparingInt(Event::eventRankId)))));
return distanceEventsMap.values()
.stream()
.flatMap(Set::stream)
.limit(number)
.collect(Collectors.toList());
}
Hiç yorum yok:
Yorum Gönder