1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[cfg(not(feature = "std"))]
use alloc::collections::BTreeSet;
#[cfg(feature = "std")]
use std::collections::BTreeSet;

use core::borrow::Borrow;

use super::super::*;

impl<V> Collection for BTreeSet<V>
where
    V: Eq + Ord,
{
    #[inline(always)]
    fn len(&self) -> usize {
        BTreeSet::<V>::len(self)
    }
}

impl<V> CollectionMut for BTreeSet<V>
where
    V: Eq + Ord,
{
    #[inline(always)]
    fn clear(&mut self) {
        BTreeSet::<V>::clear(self);
    }
}

impl<V> Create<V> for BTreeSet<V>
where
    V: Eq + Ord,
{
    #[inline(always)]
    fn create() -> Self {
        BTreeSet::<V>::new()
    }
    #[inline(always)]
    fn create_with_capacity(_: usize) -> Self {
        BTreeSet::<V>::new()
    }

    #[inline(always)]
    fn add_element(mut self, value: V) -> Self {
        BTreeSet::<V>::insert(&mut self, value);
        self
    }
}

impl<V> Add<V> for BTreeSet<V>
where
    V: Eq + Ord,
{
    type Output = bool;

    #[inline(always)]
    fn add(&mut self, v: V) -> Self::Output {
        BTreeSet::<V>::insert(self, v)
    }
}

impl<'a, Q, V> Get<&'a Q> for BTreeSet<V>
where
    Q: Eq + Ord + ?Sized,
    V: Eq + Ord + Borrow<Q>,
{
    type Output = V;

    #[inline(always)]
    fn get(&self, q: &Q) -> Option<&Self::Output> {
        BTreeSet::<V>::get(self, q)
    }
}