mapping - Can Java Streams transform a list of points into a list of their coordinates? -


i have stream of point3ds in javafx 8 program. like, sake of creating mesh them, able produce list of (x, y, z) coordinates instead.

this simple enough task through traditional java looping. (almost trivial, actually.) however, in future, i'll dealing tens of thousands of points; , able use java stream api , accomplish parallel stream.

i suppose i'm looking rough equivalent of psuedocode:

list<double> coordinates = stream.parallel().map(s -> (s.getx(), s.gety(), s.getz())).collect(collectors.aslist()); 

as of yet, i've found no such feature though. kindly give me push in right direction?

you can use flatmap :

list<double> coordinates =      stream.parallel()           .flatmap(s -> stream.of(s.getx(), s.gety(), s.getz()))           .collect(collectors.aslist()); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -