diff options
| author | yanchith <yanchi.toth@gmail.com> | 2023-06-09 11:48:11 +0200 |
|---|---|---|
| committer | yanchith <yanchi.toth@gmail.com> | 2023-06-09 11:48:11 +0200 |
| commit | 7a9f282528fe95e160b177b880e06cc5ca2a426a (patch) | |
| tree | 3464179fb972225af332a8b08944daaa3d811412 /library/alloc/src | |
| parent | cb5c011670ce8d073d0aae8c45e73c20593bfa11 (diff) | |
Reallocatorize after merge
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/binary_heap/mod.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index f5e6bd20ea5..abc29b32bbc 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -280,7 +280,6 @@ pub struct BinaryHeap< data: Vec<T, A>, } -// XXX: PeekMut<A> /// Structure wrapping a mutable reference to the greatest item on a /// `BinaryHeap`. /// @@ -289,8 +288,12 @@ pub struct BinaryHeap< /// /// [`peek_mut`]: BinaryHeap::peek_mut #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] -pub struct PeekMut<'a, T: 'a + Ord> { - heap: &'a mut BinaryHeap<T>, +pub struct PeekMut< + 'a, + T: 'a + Ord, + #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, +> { + heap: &'a mut BinaryHeap<T, A>, // If a set_len + sift_down are required, this is Some. If a &mut T has not // yet been exposed to peek_mut()'s caller, it's None. original_len: Option<NonZeroUsize>, @@ -359,11 +362,10 @@ impl<'a, T: Ord, A: Allocator + 'a> DerefMut for PeekMut<'a, T, A> { } } -// XXX: PeekMut<A> impl<'a, T: Ord, A: Allocator + 'a> PeekMut<'a, T, A> { /// Removes the peeked value from the heap and returns it. #[stable(feature = "binary_heap_peek_mut_pop", since = "1.18.0")] - pub fn pop(mut this: PeekMut<'a, T>) -> T { + pub fn pop(mut this: PeekMut<'a, T, A>) -> T { if let Some(original_len) = this.original_len.take() { // SAFETY: This is how many elements were in the Vec at the time of // the BinaryHeap::peek_mut call. @@ -404,18 +406,21 @@ impl<T: fmt::Debug, A: Allocator> fmt::Debug for BinaryHeap<T, A> { } } -struct RebuildOnDrop<'a, T: Ord> { - heap: &'a mut BinaryHeap<T>, +struct RebuildOnDrop< + 'a, + T: Ord, + #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, +> { + heap: &'a mut BinaryHeap<T, A>, rebuild_from: usize, } -impl<'a, T: Ord> Drop for RebuildOnDrop<'a, T> { +impl<'a, T: Ord, A: Allocator> Drop for RebuildOnDrop<'a, T, A> { fn drop(&mut self) { self.heap.rebuild_tail(self.rebuild_from); } } -// XXX: BinaryHeap<T, A> impl<T: Ord> BinaryHeap<T> { /// Creates an empty `BinaryHeap` as a max-heap. /// @@ -501,7 +506,6 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> { BinaryHeap { data: Vec::with_capacity_in(capacity, alloc) } } - // XXX: peek_mut /// Returns a mutable reference to the greatest item in the binary heap, or /// `None` if it is empty. /// @@ -533,7 +537,7 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> { /// If the item is modified then the worst case time complexity is *O*(log(*n*)), /// otherwise it's *O*(1). #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] - pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>> { + pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T, A>> { if self.is_empty() { None } else { @@ -1813,7 +1817,7 @@ impl<T: Ord, A: Allocator> Extend<T> for BinaryHeap<T, A> { } #[stable(feature = "extend_ref", since = "1.2.0")] -impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BinaryHeap<T> { +impl<'a, T: 'a + Ord + Copy, A: Allocator> Extend<&'a T> for BinaryHeap<T, A> { fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) { self.extend(iter.into_iter().cloned()); } |
