Skip to content

Commit a724ff9

Browse files
committed
Remove BinaryHeap::{push_pop,replace}
[unstable, deprecated since 1.13.0]
1 parent a76274e commit a724ff9

File tree

6 files changed

+0
-124
lines changed

6 files changed

+0
-124
lines changed

src/doc/unstable-book/src/SUMMARY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
- [as_c_str](library-features/as-c-str.md)
104104
- [as_unsafe_cell](library-features/as-unsafe-cell.md)
105105
- [ascii_ctype](library-features/ascii-ctype.md)
106-
- [binary_heap_extras](library-features/binary-heap-extras.md)
107106
- [binary_heap_peek_mut_pop](library-features/binary-heap-peek-mut-pop.md)
108107
- [borrow_state](library-features/borrow-state.md)
109108
- [box_heap](library-features/box-heap.md)

src/doc/unstable-book/src/library-features/binary-heap-extras.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/libcollections/binary_heap.rs

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -555,82 +555,6 @@ impl<T: Ord> BinaryHeap<T> {
555555
self.sift_up(0, old_len);
556556
}
557557

558-
/// Pushes an item onto the binary heap, then pops the greatest item off the queue in
559-
/// an optimized fashion.
560-
///
561-
/// # Examples
562-
///
563-
/// Basic usage:
564-
///
565-
/// ```
566-
/// #![feature(binary_heap_extras)]
567-
/// #![allow(deprecated)]
568-
///
569-
/// use std::collections::BinaryHeap;
570-
/// let mut heap = BinaryHeap::new();
571-
/// heap.push(1);
572-
/// heap.push(5);
573-
///
574-
/// assert_eq!(heap.push_pop(3), 5);
575-
/// assert_eq!(heap.push_pop(9), 9);
576-
/// assert_eq!(heap.len(), 2);
577-
/// assert_eq!(heap.peek(), Some(&3));
578-
/// ```
579-
#[unstable(feature = "binary_heap_extras",
580-
reason = "needs to be audited",
581-
issue = "28147")]
582-
#[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
583-
pub fn push_pop(&mut self, mut item: T) -> T {
584-
match self.data.get_mut(0) {
585-
None => return item,
586-
Some(top) => {
587-
if *top > item {
588-
swap(&mut item, top);
589-
} else {
590-
return item;
591-
}
592-
}
593-
}
594-
595-
self.sift_down(0);
596-
item
597-
}
598-
599-
/// Pops the greatest item off the binary heap, then pushes an item onto the queue in
600-
/// an optimized fashion. The push is done regardless of whether the binary heap
601-
/// was empty.
602-
///
603-
/// # Examples
604-
///
605-
/// Basic usage:
606-
///
607-
/// ```
608-
/// #![feature(binary_heap_extras)]
609-
/// #![allow(deprecated)]
610-
///
611-
/// use std::collections::BinaryHeap;
612-
/// let mut heap = BinaryHeap::new();
613-
///
614-
/// assert_eq!(heap.replace(1), None);
615-
/// assert_eq!(heap.replace(3), Some(1));
616-
/// assert_eq!(heap.len(), 1);
617-
/// assert_eq!(heap.peek(), Some(&3));
618-
/// ```
619-
#[unstable(feature = "binary_heap_extras",
620-
reason = "needs to be audited",
621-
issue = "28147")]
622-
#[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
623-
pub fn replace(&mut self, mut item: T) -> Option<T> {
624-
if !self.is_empty() {
625-
swap(&mut item, &mut self.data[0]);
626-
self.sift_down(0);
627-
Some(item)
628-
} else {
629-
self.push(item);
630-
None
631-
}
632-
}
633-
634558
/// Consumes the `BinaryHeap` and returns the underlying vector
635559
/// in arbitrary order.
636560
///

src/libcollections/tests/binary_heap.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -152,36 +152,6 @@ fn test_push_unique() {
152152
assert!(*heap.peek().unwrap() == box 103);
153153
}
154154

155-
#[test]
156-
#[allow(deprecated)]
157-
fn test_push_pop() {
158-
let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
159-
assert_eq!(heap.len(), 5);
160-
assert_eq!(heap.push_pop(6), 6);
161-
assert_eq!(heap.len(), 5);
162-
assert_eq!(heap.push_pop(0), 5);
163-
assert_eq!(heap.len(), 5);
164-
assert_eq!(heap.push_pop(4), 5);
165-
assert_eq!(heap.len(), 5);
166-
assert_eq!(heap.push_pop(1), 4);
167-
assert_eq!(heap.len(), 5);
168-
}
169-
170-
#[test]
171-
#[allow(deprecated)]
172-
fn test_replace() {
173-
let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
174-
assert_eq!(heap.len(), 5);
175-
assert_eq!(heap.replace(6).unwrap(), 5);
176-
assert_eq!(heap.len(), 5);
177-
assert_eq!(heap.replace(0).unwrap(), 6);
178-
assert_eq!(heap.len(), 5);
179-
assert_eq!(heap.replace(4).unwrap(), 5);
180-
assert_eq!(heap.len(), 5);
181-
assert_eq!(heap.replace(1).unwrap(), 4);
182-
assert_eq!(heap.len(), 5);
183-
}
184-
185155
fn check_to_vec(mut data: Vec<i32>) {
186156
let heap = BinaryHeap::from(data.clone());
187157
let mut v = heap.clone().into_vec();
@@ -227,13 +197,6 @@ fn test_empty_peek_mut() {
227197
assert!(empty.peek_mut().is_none());
228198
}
229199

230-
#[test]
231-
#[allow(deprecated)]
232-
fn test_empty_replace() {
233-
let mut heap = BinaryHeap::new();
234-
assert!(heap.replace(5).is_none());
235-
}
236-
237200
#[test]
238201
fn test_from_iter() {
239202
let xs = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];

src/libcollections/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![deny(warnings)]
1212

13-
#![feature(binary_heap_extras)]
1413
#![feature(binary_heap_peek_mut_pop)]
1514
#![feature(box_syntax)]
1615
#![feature(inclusive_range_syntax)]

src/test/run-pass/while-let.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// except according to those terms.
1010

1111

12-
#![feature(binary_heap_extras)]
13-
1412
use std::collections::BinaryHeap;
1513

1614
fn make_pq() -> BinaryHeap<isize> {

0 commit comments

Comments
 (0)