C
C#2y ago
augh

Is there a concurrent ordered collection?

And if there isn't, how would you find a workaround for a bunch of threads generating some data and adding it to a collection where it can be accessed by index?
4 Replies
augh
aughOP2y ago
Or could I use a concurrent dictionary. And use keys instead of indecies.
Anu6is
Anu6is2y ago
ConcurrentBag is a thing https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentbag-1?view=net-7.0 but i guess that doesn't satisfy the index thing really
mtreit
mtreit2y ago
Your original question asked about an "ordered" collection, but collections accessed by index (like lists / arrays) or by key (dictionaries) are not generally considered ordered. What are your actual requirements?
augh
aughOP2y ago
Ok it doesn't mean what I thought it meant Also I realized how stupid my initial question was
Want results from more Discord servers?
Add your server