-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 TryDequeue to Queue #15619
Comments
You can write an extension method for this. |
@benaadams do you want to try to flesh out the API proposal? Here's a link on the next steps http://aka.ms/apireview |
@zabulus my point is unless you are doing exception based flow control; which would be terribad, everyone will always be writing it; extension or explicit, so it should be a part of the system library. |
Is some one working on this already? If not I think I might be able to help with this. |
@page-not-found go for it; should be fairly straightforward |
@joshfree Can you help me on what needs to happen next? I suppose I need to show up some kind of code snippets which will be modified or something? |
@page-not-found here is a good example of a ready-to-review proposal |
Thanks @joshfree I will start working on this week 👍 |
Problem StatementAs the above discussion points it out if we don't want to code for the exception flow if there is not item to the which can be dequeued instead of throwing an exception we should be returning default of T. Proposed Changes
Usage Examples:Copied from first comment Before Change:
After Change:
Proposed Tests
I don't see any open question so far. Let me know if you thinnk there needs to more tests to be covered. |
thanks @page-not-found and @benaadams. tagging this as api-ready-for-review. |
As mentioned in #14032 TryPeek might be something to add at same time? Would follow similar pattern. |
LGTM 👍 |
@terrajobst Is there any update on this ? |
Sorry for the delay. We're currently focusing our efforts on getting to a good V1 release. This includes exposing more API that already exist in .NET Framework, which is what we focus our design meetings on. We don't spend much time on proposals to add APIs to existing types because even if were to approve them, the problem is that we don't have enough time left to add all these additions to the .NET Framework. Our goal for V1 is to have parity for the common APIs shared between .NET Core and .NET Framework. That's why this issue currently sits in milestone 'Future'. |
This reverts commit d19afae.
This looks useful. We should probably add
To make things consistent. |
System.Collections.Generic.Queue
does not have aTryDequeue
method, however itsDequeue
is a throwing method so the following pattern always has to be used:with extra boilerplate for for whatever no item handling; this would be better as:
As per
ConcurrentQueue
orTryGet
of DictionaryThe text was updated successfully, but these errors were encountered: