Questions tagged [collect]

Use this tag for questions related to the act of gathering/collecting/grouping data/results from several nodes/places/computers to one (or main) resource(s).

Use this tag for questions related to the act of gathering/collecting/grouping data/results from several nodes/places/computers to one (or main) resource(s).

For example, in Distributed Computing, the slaves would do their local computation and eventually, one would like the master to collect the (local) results.

354 questions
-2
votes
1 answer

How to do Map from Stream> in java stream API?

Oh. I have Java 8 and want to collect a Map from Stream> I do not want to use Pair, because of verbose syntax. Is there any way to do .collect(toMap(Tuple2::_1, Tuple2::_2)) Thanx
Igor Yudnikov
  • 434
  • 1
  • 6
  • 14
-2
votes
1 answer

Double Java Stream not leaving when wanted

Here is my problem. public LinkedHashSet findAllQuizByCompanyAndCategory(List quizList, String quizCategoryId) { int i = 1; return hibernateQuizJpaRepository .findAllByCategorySetContaining(new…
-2
votes
8 answers

Complex multi-dimensional list operations in Scala

Given a list such as the following: val dane = List( ("2011-01-04", -137.76), ("2011-01-04", 2376.45), ("2011-01-04", -1.70), ("2011-01-04", -1.70), ("2011-01-04", -1.00), // ... skip a few ... ("2011-12-22", -178.02), …
Kamil
  • 467
  • 2
  • 13
-2
votes
1 answer

Guava's ImmutableTable filtering via Java 8 parallel stream

Need help in filtering Guava's ImmutableTable via parallel stream and collector Immutable tofilterTable; Usecase : Iterate over toFilter and remove elements which are not present or entry value is false in validEntry table. Tradition way of…
sidss
  • 923
  • 1
  • 12
  • 20
-2
votes
1 answer

Collect removes 0 when converting from string to integer

When I use collect(&:to_i) to change an array of strings to an array of integers, if the string at index position 0 is "0" it is removed when the array is converted. For example: n = "0123456789" number = n.split array = number.collect(&:to_i) =>…
SmellydogCoding
  • 414
  • 8
  • 23
-4
votes
1 answer

Java 8 code to concatenate a List of Strings without duplicates

I have a Hit class and a List that contains something like this: {{id=1, list="EU"}, {id=2, list="EU,OF,UN"}} How can I get some concatenated lists without doubled occurrences? I tried something like this: Set sourceList =…
WDrgn
  • 521
  • 10
  • 29
-4
votes
1 answer

How to add all numbers within a range in an array? then find the average of that range

I have a problem with C++ and I dont know how to start this code since I am new to this. My problem is I have a BUNCH of arrays and the one below is ONE example. From the bunch of arrays I have to find all the numbers present from a range of 0.0 to…
salvax18
  • 3
  • 3
-6
votes
1 answer

Array to Map: no suitable method found for Collectors.toMap

I want to convert array into Map using Java 8 streams: String[] arr = {"two", "times", "two", "is", "four"}; Arrays.stream(arr).collect(Collectors.toMap(s -> s, 1, Integer::sum); The s -> s part is marked as error no instance(s) of type…
1 2 3
23
24