Giter Club home page Giter Club logo

Comments (7)

BlueRaja avatar BlueRaja commented on May 17, 2024

There is definitely a way to do this and get the same performance without that extreme coupling.

No, there isn't. Have you read this?

That being said, I have created an implementation which is safer and easier to use (safety checks in the release version, thread-safe, enqueues any object), but haven't had time to test and release it yet. I will try to get around to that soon.

from high-speed-priority-queue-for-c-sharp.

alibad avatar alibad commented on May 17, 2024

Ok, that adds some more context. But still...

Let me give you this very simple example. I have an int. Now I have to create an IntWrapper class, make it inherit from your class, take the cost of storing all the 3 extra properties (double, long, long), take in the extra cost of allocation, with the added disadvantage of complexity. Too much overhead for what someone would be looking for in a priority queue.

A priority queue is mainly used to enqueue and dequeue by priority (Min heap or max heap), not to check if the queue contains a certain value. You implementation is not improving performance of expected operations on a priority queue (in fact it's slightly adding a bit perf\memory overhead on those operations). If you want to optimize for lookup, just use a different data structure.

from high-speed-priority-queue-for-c-sharp.

BlueRaja avatar BlueRaja commented on May 17, 2024

A normal priority queue will have the exact same overhead, it will just be hidden from you (at the cost of a small amount of speed).

This priority queue was originally written to be as fast as humanly possible for path-finding applications specifically, so enqueuing primitives wasn't an initial design consideration. However, as I said above, I've now written a more widely-applicable implementation, I just need to find time to test and publish it.

from high-speed-priority-queue-for-c-sharp.

BlueRaja avatar BlueRaja commented on May 17, 2024

I've pushed what I have so far to the SafePriorityQueue branch. The 'fast' queue has been renamed to FastPriorityQueue, while the 'convenient' queue is SafePriorityQueue.

Please be aware that some behavior is liable to change (eg. I'm not sure if I want First to return null or throw an exception when the queue is empty; or if duplicate keys should be allowed in SafePriorityQueue since they cannot be allowed in FastPriorityQueue)

from high-speed-priority-queue-for-c-sharp.

BlueRaja avatar BlueRaja commented on May 17, 2024

I've completed the implementation and created a PR: #2. Would you like to test it out before I merge?

from high-speed-priority-queue-for-c-sharp.

BlueRaja avatar BlueRaja commented on May 17, 2024

PR has been merged! The new implementation is called SimplePriorityQueue. It doesn't have the coupling issues, it automatically resizes, it contains lots of safety checks, and it's thread-safe.

The original priority queue has been renamed to FastPriorityQueue.

from high-speed-priority-queue-for-c-sharp.

alibad avatar alibad commented on May 17, 2024

Hi Raja,

Sorry I haven't been able to respond and review. Glad to see the improvements!

Sent from my Phone

On Jan 4, 2016, at 3:01 AM, BlueRaja [email protected] wrote:

PR has been merged! The new implementation is called SimplePriorityQueue. It doesn't have the coupling issues, it automatically resizes, it contains lots of safety checks, and it's thread-safe.


Reply to this email directly or view it on GitHub.

from high-speed-priority-queue-for-c-sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.