sphinxy / DataStructures

Concurrent priority queue and skip list for .NET
MIT License
42 stars 22 forks source link

Nuget Package? #1

Closed gkinsman closed 9 years ago

gkinsman commented 9 years ago

I know the priority queue is on nuget, but is it as up to date as the implementation here? (This one has newer commits.) Perhaps you could please put this in a nuget package so I don't need to take a source dependency :).

Thanks!

dshulepov commented 9 years ago

Ok, I'll see if it's already time to create a package. The thing is that I've changed the signatures for PriorityQueue and also implemented differently some of the methods. I think this repo contains more tests, but you never know when you introduce a bug. Also the SkipList is not completely done and I was thinking on adding some more features and tests to it... Anyway, I'll review the code ones again with a fresh head and will let you know what's the state with the nuget package.

dshulepov commented 9 years ago

It would be nice if you could check the new signatures in PriorityQueue and verify that it matches what you need and also it would be nice if you could let me know what do you use it for (so I could extend the list of applications on the main page :) )

gkinsman commented 9 years ago

No problem, I just thought it might be worth tracking it somewhere for others interested :).

I'm using it for a best-search on a tree, which is already listed as one of your usages. I have a couple comments/questions :).

It looks like a great implementation, and it's been working flawlessly for me so far!

dshulepov commented 9 years ago

Thanks for the feetback.

I wanted to make the PriorityQueue implement a common .NET interface and the obvious chose is the ICollection. Unfortunatelly they did not introduce the interface for a queue. I looked at the SortedList and the ConcurrentQueue and none of those have any suitable interface. Implementing an ICollection is a questionalbe decision since on one hand PriorityQueue is not just a collection - it garanties you a certain order, on the other hand you add and remove items from it. SkipList also implements an ICollection, so they are somewhat similar in that. Also, I wanted ConcurrentPriorityQueue and ConcurrentSkipList to implement IProducerConsumer collection, which is inherited from ICollection, so it all somehow lead to decision. However, because of ICollection interface the API of PriorityQueue does not have the Enqueue and Dequeue methods, which, I though, would be too much. May be you, or someone else would have a good reasoning to add them.

As for the none TryXxx methods in ConcurrentXxx classes - they all are thread safe, so you could use any. In fact the only really noticable difference is the TryTake vs Take. TryTake will just return false if the collection is empty, while Take will throw and Exception.

dshulepov commented 9 years ago

Ok. The nuget package is there. I'll close this one, but if you have any other issues, you know what to do :)