1
Fork 0

Add BinaryHeap::retain as suggested in #42849

This commit is contained in:
arlo 2020-04-23 14:07:50 -05:00
parent 00f677d897
commit 787eddc1ab
3 changed files with 37 additions and 0 deletions

View file

@ -372,6 +372,14 @@ fn assert_covariance() {
}
}
#[test]
fn test_retain() {
let mut a = BinaryHeap::from(vec![-10, -5, 1, 2, 4, 13]);
a.retain(|x| x % 2 == 0);
assert_eq!(a.into_sorted_vec(), [-10, 2, 4])
}
// old binaryheap failed this test
//
// Integrity means that all elements are present after a comparison panics,