Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SortedBag<T> for C# [closed]

I'm looking for a SortedBag implementation for C#, my use case is the following: I have a series of objects that are being estimated and sorted out using custom IComparer implementation, the problem is that totally different objects may yield to the same estimate, and when I'm trying to use C#'s default sorted collections such as SortedSet, SortedDictionary implementations, I'm unable to insert several objects to these collections with the same estimate because collections consider these objects equal and refuse to insert them. I need a SortedBag implementation that has O(log(N)) for insertion and removal since I'm doing inserts/removals pretty actively.

Has anyone stumbled upon such implementation?

Thank you!

Edit

It seems that I was looking for Priority Queue not the SortedBag...

like image 407
Lu4 Avatar asked Mar 23 '23 14:03

Lu4


1 Answers

The TreeBag<T> from the The C5 Generic Collection Library should be O(log(n)) both in insert and in remove, otherwise there is the Wintellect's Power Collections for .NET with its OrderedBag<T>.

like image 148
xanatos Avatar answered Mar 25 '23 02:03

xanatos