Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoubleStream, LongStream, IntStream are incompatible with Stream #87

Closed
PromanSEW opened this issue Nov 26, 2016 · 3 comments
Closed

DoubleStream, LongStream, IntStream are incompatible with Stream #87

PromanSEW opened this issue Nov 26, 2016 · 3 comments

Comments

@PromanSEW
Copy link
Contributor

Why? I want to flatten double[][], but I can't
Stream.of(dm).flatMap(DoubleStream::of) says about incompatible types, because DoubleStream extends Object, not Stream
And Stream.ofcan't process primitive types - result is still double[]
I think this problem was fixed in 1.1.4
How to flatten multidimensional arrays of primitives?
Maybe I missed something?

@aNNiMON
Copy link
Owner

aNNiMON commented Nov 26, 2016

Class Stream represents object stream, use IntStream, LongStream, DoubleStream for primitives.

To flatten double[][] use flatMapToDouble:

DoubleStream doubles = Stream.of(dm).flatMapToDouble(DoubleStream::of);

@PromanSEW
Copy link
Contributor Author

Thanks, I don't know about these new methods

@aNNiMON
Copy link
Owner

aNNiMON commented Nov 26, 2016

That's all right. There are special methods to convert between Streams:

from \ to Stream IntStream LongStream DoubleStream
Stream map / flatMap mapToInt / flatMapToInt mapToLong / flatMapToLong mapToDouble / flatMapToDouble
IntStream mapToObj map / flatMap mapToLong mapToDouble
LongStream mapToObj mapToInt map / flatMap mapToDouble
DoubleStream mapToObj mapToInt mapToLong map / flatMap

@aNNiMON aNNiMON closed this as completed Nov 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants