Skip to content
New issue

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

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

Already on GitHub? # to your account

Return Stream[] or List<Stream> chunks for combinations #22

Open
ghYura opened this issue Apr 16, 2023 · 0 comments
Open

Return Stream[] or List<Stream> chunks for combinations #22

ghYura opened this issue Apr 16, 2023 · 0 comments

Comments

@ghYura
Copy link

ghYura commented Apr 16, 2023

Please, implement for all Generators:
Return -array[] or -List() of chunked Streams of precalculated (but not yet generated as output) combinations
according to input parallel thread number as a divisor for total precalculated number of output combinations, i.g.:

   int n = Runtime.getRuntime().availableProcessors();
   assert n == 8;
   Generator.combination("red", "black", "white", "green", "blue")
       .simple(3)
       .asArrayOfStreamsForGivenThreads(n) //returns Stream[] or List<Stream>
       .stream()
       .parallel()
       .forEach(e->e.forEach(System.out::println));

so, therefore user can process in parallel in chunks:

   [red, black, white] // 0-stream 1st output
   [red, black, green] // 0-stream 2nd output
   [red, black, blue] // 2-stream 1st output
   [red, white, green] // 2-stream 2nd output
   [red, white, blue] // 4-stream 1st output
   [red, green, blue] // 4-stream 2nd output
   [black, white, green] // 1-stream 1st output
   [black, white, blue] // 1-stream 2nd output
   [black, green, blue] // 3-stream 1st output
   [white, green, blue] // 3-stream 2nd output 
   
   //total output ==10 //out of 5-capacity array or list

(5 streams - since it is best match for given threads divisor 10/8 == Math.ceil(5/4) == 2 (so total output 10/per 2 = 5 element-array or list) for output number of array.length or list.size() but precalculated number of total output ==10)
Please note:

  1. It is important, that array Stream[] or List should not be prefilled by output generated data, just chunks of stream to be used for further parallel processing

  2. In Mathmatics, there are some formulas exist for every type of combination (total output number)

Thank you

@ghYura ghYura changed the title Return Streams[] or List<Stream> chunks for combinations Return Stream[] or List<Stream> chunks for combinations Apr 17, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant