alloc: Added as_slice
method to BinaryHeap
collection
This commit is contained in:
parent
da5f7f1093
commit
6233f3f4a3
2 changed files with 24 additions and 0 deletions
|
@ -889,6 +889,29 @@ impl<T> BinaryHeap<T> {
|
||||||
self.data.shrink_to(min_capacity)
|
self.data.shrink_to(min_capacity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a slice of all values in the underlying vector, in arbitrary
|
||||||
|
/// order.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// Basic usage:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(binary_heap_as_slice)]
|
||||||
|
/// use std::collections::BinaryHeap;
|
||||||
|
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
|
||||||
|
/// let slice = heap.as_slice();
|
||||||
|
///
|
||||||
|
/// // Will print in some order
|
||||||
|
/// for x in slice {
|
||||||
|
/// println!("{}", x);
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
#[unstable(feature = "binary_heap_as_slice", issue = "82331")]
|
||||||
|
pub fn as_slice(&self) -> &[T] {
|
||||||
|
self.data.as_slice()
|
||||||
|
}
|
||||||
|
|
||||||
/// Consumes the `BinaryHeap` and returns the underlying vector
|
/// Consumes the `BinaryHeap` and returns the underlying vector
|
||||||
/// in arbitrary order.
|
/// in arbitrary order.
|
||||||
///
|
///
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#![feature(binary_heap_drain_sorted)]
|
#![feature(binary_heap_drain_sorted)]
|
||||||
#![feature(slice_ptr_get)]
|
#![feature(slice_ptr_get)]
|
||||||
#![feature(binary_heap_retain)]
|
#![feature(binary_heap_retain)]
|
||||||
|
#![feature(binary_heap_as_slice)]
|
||||||
#![feature(inplace_iteration)]
|
#![feature(inplace_iteration)]
|
||||||
#![feature(iter_map_while)]
|
#![feature(iter_map_while)]
|
||||||
#![feature(int_bits_const)]
|
#![feature(int_bits_const)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue