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

BinaryHeap-from-Vec should document that it's non-allocating and O(n) #58769

Closed
scottmcm opened this issue Feb 27, 2019 · 3 comments
Closed

BinaryHeap-from-Vec should document that it's non-allocating and O(n) #58769

scottmcm opened this issue Feb 27, 2019 · 3 comments
Labels
A-collections Area: `std::collection` needs-fcp This change is insta-stable, so needs a completed FCP to proceed. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

https://doc.rust-lang.org/beta/std/collections/struct.BinaryHeap.html#impl-From%3CVec%3CT%3E%3E

From the code, this seems to be an allocation-reusing O(n) make_heap, which is a very useful operation, so it would be nice for it to be documented as being such.

@Centril Centril added A-collections Area: `std::collection` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. labels Feb 27, 2019
@sekineh
Copy link
Contributor

sekineh commented Oct 2, 2019

This issue seems to be already done as of 2019-08-12:

ff497332 src/libcollections/binary_heap.rs       (Alex Crichton              2015-10-22 16:28:45 -0700 1282) impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
e30480ca src/liballoc/collections/binary_heap.rs (Observer42                 2019-08-12 18:07:14 +0800 1283)     /// Converts a `Vec<T>` into a `BinaryHeap<T>`.
fa7a40cc src/liballoc/collections/binary_heap.rs (Observer42                 2019-08-12 16:07:13 +0800 1284)     ///
e30480ca src/liballoc/collections/binary_heap.rs (Observer42                 2019-08-12 18:07:14 +0800 1285)     /// This conversion happens in-place, and has `O(n)` time complex
ity.
ff497332 src/libcollections/binary_heap.rs       (Alex Crichton              2015-10-22 16:28:45 -0700 1286)     fn from(vec: Vec<T>) -> BinaryHeap<T> {

@sekineh
Copy link
Contributor

sekineh commented Oct 2, 2019

Included in:
#63486

@scottmcm
Copy link
Member Author

scottmcm commented Oct 2, 2019

Agreed, @sekineh; thanks for commenting!

@scottmcm scottmcm closed this as completed Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: `std::collection` needs-fcp This change is insta-stable, so needs a completed FCP to proceed. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants