I find myself very intrigued by the existence of a ConcurrentBag
Bags are useful for storing objects wh
If you look at the details of ConcurrentBag
, you'll find that it's, internally, basically a customized linked list.
Since Bags can contain duplicates, and are not accessible by index, a doubly linked list is a very good option for implementation. This allows locking to be fairly fine grained for insert and removal (you don't have to lock the entire collection, just the nodes around where you're inserting/removing). Since you're not worried about duplicates, no hashing is involved. This makes a double linked list perfect.