Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SimplePriorityQueue.Try...() overloads that expose priority as out parameter #55

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

JohannesMP
Copy link

@JohannesMP JohannesMP commented Jul 26, 2021

  • Add SimplePriorityQueue.TryDequeue() overload with out TPriority parameter and relevant unit tests
  • Add SimplePriorityQueue.TryRemove() overload with out TPriority parameter and relevant unit tests
  • Add SimplePriorityQueue.TryFirst() overload with out TPriority parameter and relevant unit tests

In each case if the caller wants the priority of the head/head-to-be-removed/node-to-be-removed, they can now get it without an additional (Try)GetPriority call, making it easier to remain thread-safe while also avoiding an extra _itemToNodesCache lookup.

See issue #54

/// Returns true if successful; false if queue was empty
/// O(log n)
/// </summary>
public bool TryDequeue(out TItem first, out TPriority firstPriority)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a duplicate method. Create method, that dequeues simple node (private bool TryDequeue(out SimpleNode node)) and use it in both TryDequeue overrides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants