Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Typo HOT 1
- Reused nodes QueueIndex breaks debug HOT 2
- Upgrade PCL project to .NET Standard Class Library HOT 1
- DLL Can't be found HOT 2
- NUnit tests do not run in debug in Visual Studio 2019 HOT 1
- Documentation contradicts examples HOT 2
- Assembly name has a space in it. HOT 2
- FastQueue doesn't return some nodes in some cases HOT 3
- Add constructor accepting FastPriorityQueue's backing array to minimize allocation HOT 1
- Thread safety HOT 1
- is it necessary to have restriction for IComparable? HOT 2
- Add strong name to this NuGet HOT 2
- Proposal: SimplePriorityQueue overloads that expose priority when trivial, for performance and thread safety HOT 1
- StablePriorityQueue is not stable. HOT 1
- Proposal: Add Targets for Other .NET Runtimes Explicitly HOT 2
- Look into C# 10 INumber interface
- Dequeue Performance HOT 3
- Dequeue of FastPriorityQueue returned in wrong order HOT 2
- Add OrderedEnumerator function
- Bug: Last item in queue is not in correct order HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from high-speed-priority-queue-for-c-sharp.