I am looking for a way to use a IJobParallelFor job that would return a NativeList or NativeQueue for each item of the input NativeArray.
NativeMultiHashMap could save me as you can fill it from different threads and add several items for each key but you actually need to define the capacity of the hash map, I don’t know that beforehand and setting a large value is not really solving the issue.
Correct me if I am wrong but you cannot do this NativeArray<NativeList<int>>
Set it to the max possible capacity. In your case it is the number of IJobParallelFor iterations you pass into the Schedule method. You should already have this value in the main thread. If you were using an IJobForEach, create an EntityQuery with the same archetype as the job, and call CalculateEntityCount and pass it into the NMHM.
Sounds like NativeStream might be what you’re looking for. There aren’t any good docs for it but you can check Packages/Collections/Unity.Collections.Tests/NativeStreamTests in any project with the Collections package for examples of how it’s used.