-
Notifications
You must be signed in to change notification settings - Fork 246
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
Use push!
and pop!
for PriorityQueue
etc
#296
Comments
Consistency is good, and |
Coming back to this since it recently annoyed me again when using a I think we should rename
|
For consistency with Base, this should probably be |
I think you mean The situation with
But, in my opinion, |
E.g. |
push!
and pop!
for Queue
push!
and pop!
for Queue
, PriorityQueue
etc
"push" and "pop" are often the name of the operations defined on a stack, i.e. something following first-in-last-out , so it's a bit of clash of terminology, but I agree
|
I think you meant that it has no insertion/extraction order, right? I do agree that the meaning of |
Revisit meaning what? Personally I like thinking of push! as "add an element to the container", whenever that makes sense in an unambiguous way. |
that's right, thanks for noticing I meant the opposite of what I wrote!
That's how I feel. I didn't mean to suggest that |
Revisit whether "add an element to the container" (when unambiguous) is the best meaning for Currently, we have the following:
✔️= implemented From this, we can see that
"Proposal 1" (which @dpsanders prefers) above suggests that "Proposal 2" above suggests that The fact that there really are two meanings for For example, if there were Cc: @StefanKarpinski |
That's a great analysis, thanks! |
I'm going to post this on Discourse for more visibility. |
Just a quick addendum to Kevin's very useful chart: for SortedSet and SortedDict, pushfirst! does not make sense but popfirst! does. Also, if we are looking forward to Julia 2.0, could someone start a list of semantic anomalies and other rough edges of DataStructures that deserve attention? I have a couple more of these. |
Please make them as seperate issues each, and apply a common tag to them. |
Thanks, updated! |
Hilariously (to me), the source of this pain is "past me":
🙈 |
Discourse link: https://discourse.julialang.org/t/taking-push-and-pop-seriously-in-julia-2-0/34326 (Tables look better in github) |
I think this PR may be relevant JuliaLang/julia#34274 (Define push! and popfirst! for AbstractChannel) |
We should do this. we should do:
to match |
push!
and pop!
for Queue
, PriorityQueue
etcpush!
and pop!
for PriorityQueue
etc
Queue is done but PriorityQueue remains |
We should use
push!
andpop!
instead ofenqueue!
anddequeue!
,so that different data structures are interchangeable without changing code.
cf. #289
The text was updated successfully, but these errors were encountered: