diff options
| author | bors <bors@rust-lang.org> | 2018-03-28 22:18:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-03-28 22:18:13 +0000 |
| commit | d52c44ea8df9f9045e6059cb2d37df743be50bb1 (patch) | |
| tree | c23ef9f643221d7f4b1869f7a681248cff99f304 /src/liballoc/binary_heap.rs | |
| parent | e5277c1457d397f22ba18a1d40c1318729becbb4 (diff) | |
| parent | 30560bb99a8875560bbad9030715520b8300110c (diff) | |
| download | rust-d52c44ea8df9f9045e6059cb2d37df743be50bb1.tar.gz rust-d52c44ea8df9f9045e6059cb2d37df743be50bb1.zip | |
Auto merge of #49460 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests - Successful merges: #49243, #49329, #49364, #49400, #49405, #49427, #49428, #49429, #49439, #49442, #49444, #49452 - Failed merges:
Diffstat (limited to 'src/liballoc/binary_heap.rs')
| -rw-r--r-- | src/liballoc/binary_heap.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/liballoc/binary_heap.rs b/src/liballoc/binary_heap.rs index 8aaac5d6e08..f6a666b599b 100644 --- a/src/liballoc/binary_heap.rs +++ b/src/liballoc/binary_heap.rs @@ -509,6 +509,31 @@ impl<T: Ord> BinaryHeap<T> { self.data.shrink_to_fit(); } + /// Discards capacity with a lower bound. + /// + /// The capacity will remain at least as large as both the length + /// and the supplied value. + /// + /// Panics if the current capacity is smaller than the supplied + /// minimum capacity. + /// + /// # Examples + /// + /// ``` + /// #![feature(shrink_to)] + /// use std::collections::BinaryHeap; + /// let mut heap: BinaryHeap<i32> = BinaryHeap::with_capacity(100); + /// + /// assert!(heap.capacity() >= 100); + /// heap.shrink_to(10); + /// assert!(heap.capacity() >= 10); + /// ``` + #[inline] + #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + pub fn shrink_to(&mut self, min_capacity: usize) { + self.data.shrink_to(min_capacity) + } + /// Removes the greatest item from the binary heap and returns it, or `None` if it /// is empty. /// |
