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

Fix bug in "k-largest numbers" code #4

Merged
merged 1 commit into from
Feb 2, 2020
Merged

Fix bug in "k-largest numbers" code #4

merged 1 commit into from
Feb 2, 2020

Conversation

briangordon
Copy link
Contributor

Previously the code produced results in an undefined order.

Calling new ArrayList(minHeap) will get the elements out of minHeap
using minHeap.toArray() but the Javadoc for PriorityQueue.toArray says
that "The elements are in no particular order."

https://docs.oracle.com/javase/8/docs/api/java/util/PriorityQueue.html#toArray--

Previously the code produced results in an undefined order. 

Calling new ArrayList(minHeap) will get the elements out of minHeap 
using minHeap.toArray() but the Javadoc for PriorityQueue.toArray says 
that "The elements are in no particular order."
@teivah teivah merged commit 1620f67 into teivah:master Feb 2, 2020
@teivah
Copy link
Owner

teivah commented Feb 2, 2020

Thanks @briangordon 🙇

@briangordon briangordon deleted the patch-1 branch February 2, 2020 09:46
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.

2 participants