data_structure_traits/collections/
binary_heap.rs

1#[cfg(not(feature = "std"))]
2use alloc::collections::BinaryHeap;
3#[cfg(feature = "std")]
4use std::collections::BinaryHeap;
5
6use super::super::*;
7
8impl<V> Collection for BinaryHeap<V>
9where
10    V: Ord,
11{
12    #[inline(always)]
13    fn len(&self) -> usize {
14        BinaryHeap::<V>::len(self)
15    }
16}
17
18impl<V> CollectionMut for BinaryHeap<V>
19where
20    V: Ord,
21{
22    #[inline(always)]
23    fn clear(&mut self) {
24        BinaryHeap::<V>::clear(self);
25    }
26}
27
28impl<V> Create<V> for BinaryHeap<V>
29where
30    V: Ord,
31{
32    #[inline(always)]
33    fn create() -> Self {
34        BinaryHeap::<V>::new()
35    }
36    #[inline(always)]
37    fn create_with_capacity(_: usize) -> Self {
38        BinaryHeap::<V>::new()
39    }
40
41    #[inline(always)]
42    fn add_element(mut self, value: V) -> Self {
43        BinaryHeap::<V>::push(&mut self, value);
44        self
45    }
46}
47
48impl<V> Add<V> for BinaryHeap<V>
49where
50    V: Ord,
51{
52    type Output = ();
53
54    #[inline(always)]
55    fn add(&mut self, v: V) -> Self::Output {
56        BinaryHeap::<V>::push(self, v)
57    }
58}