Nick Samoylov's Blog, page 2

August 2, 2020

Java streams 35. Collect 11. Collectors.partitioningBy() collector

The Collectors.partitioningBy() collector breaks the stream elements in two groups – one contains elements that fit the specified criteria and another one that contains elements that do not fit the specified criteria.


The post Java streams 35. Collect 11. Collectors.partitioningBy() collector appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on August 02, 2020 10:12

July 25, 2020

Java streams 34. Collect 10. Collectors.groupingByConcurrent() collector

Creating a Map object from Stream elements using Collectors.groupingByConcurrent() yields better performance (than .groupingBy())) while processing a parallel stream.


The post Java streams 34. Collect 10. Collectors.groupingByConcurrent() collector appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on July 25, 2020 18:27

Java streams 32. Collect 8. Collectors.toConcurrentMap() collector

Creating a Map object from Stream elements using Collectors.toConcurrentMap() yields better (than .toMap()) performance while processing a parallel stream.


The post Java streams 32. Collect 8. Collectors.toConcurrentMap() collector appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on July 25, 2020 15:33

July 18, 2020

Java streams 33. Collect 9. Collectors.groupingBy() collector

Creating a Map object from Stream elements using Collectors.groupingBy() allows for a lot of flexibilit


The post Java streams 33. Collect 9. Collectors.groupingBy() collector appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on July 18, 2020 10:39

JavaStream 32. Collect 8. Collectors.groupingBy() collector

Creating a Map object from Stream elements using Collectors.groupingBy() allows for a lot of flexibilit


The post JavaStream 32. Collect 8. Collectors.groupingBy() collector appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on July 18, 2020 10:39

July 16, 2020

Java streams 31. Collect 7. Collectors.toMap() collector

Creating Map with keys and values based on the elements emitted by a stream is easy, if one uses the ready-to-use collectors from Collectors class. Let’s start with the simplest of map collectors toMap().


The post Java streams 31. Collect 7. Collectors.toMap() collector appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on July 16, 2020 18:40

July 15, 2020

Java streams 30. Collect 6. Collectors.toList(), .toSet(), and .toCollection()

Creating List or Set object or any collection from stream elements is easy. Just call collect() operation and pass the corresponding collector, generated by one of the factory methods of the Collectors class.


The post Java streams 30. Collect 6. Collectors.toList(), .toSet(), and .toCollection() appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on July 15, 2020 16:17

June 30, 2020

Wittgenstein 8. Final thoughts

He was unusual in his ways of life and thinking. His strangeness attracted attention, along with his prophetic literary style. Such a style requires an interpretation and, naturally, the reader comes with the interpretation that makes sense to them. The reader becomes a co-author.


The post Wittgenstein 8. Final thoughts appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on June 30, 2020 12:41

June 28, 2020

Java streams 28. Collect 4. Counting stream elements

The collect(Collectors.counting()) is a very straightforward operation. It counts a number of emitted elements. But it does a bit more than the Stream operator count().


The post Java streams 28. Collect 4. Counting stream elements appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on June 28, 2020 10:34

Java streams 27. Collect 3. Collectors summing, averaging, and summarizing.

In this post, we will discuss and demonstrate usage of the ready-to-use collectors that calculate some statistics of the stream elements – count, sum, average, min, and max element of the stream.


The post Java streams 27. Collect 3. Collectors summing, averaging, and summarizing. appeared first on Nick Samoylov, programmer and writer.

 •  0 comments  •  flag
Share on Twitter
Published on June 28, 2020 10:34