BlueRaja / High-Speed-Priority-Queue-for-C-Sharp

A C# priority queue optimized for pathfinding applications
MIT License
1.15k stars 169 forks source link

Add constructor accepting FastPriorityQueue's backing array to minimize allocation #50

Closed mchandschuh closed 3 years ago

mchandschuh commented 4 years ago

For my use case, I'll have an unknown number of queues processing at the same time and in quick succession. It would be ideal if I could use ArrayPool to pool array allocations and then initialize FastPriorityQueue using the pool sourced array.

BlueRaja commented 3 years ago

I'm not sure if there's a way to make this faster than just calling .Clear(). The heap relies on the array being zero-initialized - if the backing array is reused between instances without being cleared, it's possible for Contains() to give a false-positive.

[Edit] Going to close this because of the above issue. If you disagree, please reopen.