]> git.lizzy.rs Git - rust.git/commitdiff
Remove BinaryHeap::{push_pop,replace}
authorJosh Stone <jistone@redhat.com>
Thu, 20 Apr 2017 20:36:23 +0000 (13:36 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 21 Apr 2017 04:16:31 +0000 (21:16 -0700)
[unstable, deprecated since 1.13.0]

src/doc/unstable-book/src/SUMMARY.md
src/doc/unstable-book/src/library-features/binary-heap-extras.md [deleted file]
src/libcollections/binary_heap.rs
src/libcollections/tests/binary_heap.rs
src/libcollections/tests/lib.rs
src/test/run-pass/while-let.rs

index b803b6556cfa1fabb93a1ff2f5b9228ff046c12b..4951ff7965a898890a3234fa3d292e649e0e7a27 100644 (file)
     - [as_c_str](library-features/as-c-str.md)
     - [as_unsafe_cell](library-features/as-unsafe-cell.md)
     - [ascii_ctype](library-features/ascii-ctype.md)
-    - [binary_heap_extras](library-features/binary-heap-extras.md)
     - [binary_heap_peek_mut_pop](library-features/binary-heap-peek-mut-pop.md)
     - [borrow_state](library-features/borrow-state.md)
     - [box_heap](library-features/box-heap.md)
diff --git a/src/doc/unstable-book/src/library-features/binary-heap-extras.md b/src/doc/unstable-book/src/library-features/binary-heap-extras.md
deleted file mode 100644 (file)
index aa535f3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# `binary_heap_extras`
-
-The tracking issue for this feature is: [#28147]
-
-[#28147]: https://github.com/rust-lang/rust/issues/28147
-
-------------------------
index 149c285a72a98d10a65aa2a2dc73b255601d24e4..e61d5b3169607122b149e3d554c2960b92497eed 100644 (file)
@@ -555,82 +555,6 @@ pub fn push(&mut self, item: T) {
         self.sift_up(0, old_len);
     }
 
-    /// Pushes an item onto the binary heap, then pops the greatest item off the queue in
-    /// an optimized fashion.
-    ///
-    /// # Examples
-    ///
-    /// Basic usage:
-    ///
-    /// ```
-    /// #![feature(binary_heap_extras)]
-    /// #![allow(deprecated)]
-    ///
-    /// use std::collections::BinaryHeap;
-    /// let mut heap = BinaryHeap::new();
-    /// heap.push(1);
-    /// heap.push(5);
-    ///
-    /// assert_eq!(heap.push_pop(3), 5);
-    /// assert_eq!(heap.push_pop(9), 9);
-    /// assert_eq!(heap.len(), 2);
-    /// assert_eq!(heap.peek(), Some(&3));
-    /// ```
-    #[unstable(feature = "binary_heap_extras",
-               reason = "needs to be audited",
-               issue = "28147")]
-    #[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
-    pub fn push_pop(&mut self, mut item: T) -> T {
-        match self.data.get_mut(0) {
-            None => return item,
-            Some(top) => {
-                if *top > item {
-                    swap(&mut item, top);
-                } else {
-                    return item;
-                }
-            }
-        }
-
-        self.sift_down(0);
-        item
-    }
-
-    /// Pops the greatest item off the binary heap, then pushes an item onto the queue in
-    /// an optimized fashion. The push is done regardless of whether the binary heap
-    /// was empty.
-    ///
-    /// # Examples
-    ///
-    /// Basic usage:
-    ///
-    /// ```
-    /// #![feature(binary_heap_extras)]
-    /// #![allow(deprecated)]
-    ///
-    /// use std::collections::BinaryHeap;
-    /// let mut heap = BinaryHeap::new();
-    ///
-    /// assert_eq!(heap.replace(1), None);
-    /// assert_eq!(heap.replace(3), Some(1));
-    /// assert_eq!(heap.len(), 1);
-    /// assert_eq!(heap.peek(), Some(&3));
-    /// ```
-    #[unstable(feature = "binary_heap_extras",
-               reason = "needs to be audited",
-               issue = "28147")]
-    #[rustc_deprecated(since = "1.13.0", reason = "use `peek_mut` instead")]
-    pub fn replace(&mut self, mut item: T) -> Option<T> {
-        if !self.is_empty() {
-            swap(&mut item, &mut self.data[0]);
-            self.sift_down(0);
-            Some(item)
-        } else {
-            self.push(item);
-            None
-        }
-    }
-
     /// Consumes the `BinaryHeap` and returns the underlying vector
     /// in arbitrary order.
     ///
index d284937a9e676a0a56ce4824c3b8abb2dd62f8b1..af18cddaddb013050ce91c6c98e32e06c6ba2ebe 100644 (file)
@@ -152,36 +152,6 @@ fn test_push_unique() {
     assert!(*heap.peek().unwrap() == box 103);
 }
 
-#[test]
-#[allow(deprecated)]
-fn test_push_pop() {
-    let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.push_pop(6), 6);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.push_pop(0), 5);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.push_pop(4), 5);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.push_pop(1), 4);
-    assert_eq!(heap.len(), 5);
-}
-
-#[test]
-#[allow(deprecated)]
-fn test_replace() {
-    let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.replace(6).unwrap(), 5);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.replace(0).unwrap(), 6);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.replace(4).unwrap(), 5);
-    assert_eq!(heap.len(), 5);
-    assert_eq!(heap.replace(1).unwrap(), 4);
-    assert_eq!(heap.len(), 5);
-}
-
 fn check_to_vec(mut data: Vec<i32>) {
     let heap = BinaryHeap::from(data.clone());
     let mut v = heap.clone().into_vec();
@@ -227,13 +197,6 @@ fn test_empty_peek_mut() {
     assert!(empty.peek_mut().is_none());
 }
 
-#[test]
-#[allow(deprecated)]
-fn test_empty_replace() {
-    let mut heap = BinaryHeap::new();
-    assert!(heap.replace(5).is_none());
-}
-
 #[test]
 fn test_from_iter() {
     let xs = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];
index 618eb386c0f4c88887b1baab32c2cc553ce64a69..9c6e31d70a541c12ac1d460ee28475aebdfab769 100644 (file)
@@ -10,7 +10,6 @@
 
 #![deny(warnings)]
 
-#![feature(binary_heap_extras)]
 #![feature(binary_heap_peek_mut_pop)]
 #![feature(box_syntax)]
 #![feature(inclusive_range_syntax)]
index 9ffba2c7999f1770966643689706329ec802a9eb..aed6986c5fe5d380b71a1fefc1fff776e0186ebe 100644 (file)
@@ -9,8 +9,6 @@
 // except according to those terms.
 
 
-#![feature(binary_heap_extras)]
-
 use std::collections::BinaryHeap;
 
 fn make_pq() -> BinaryHeap<isize> {