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
use super::BddParams;
use crate::biodivine_std::traits::Set;
use biodivine_lib_bdd::Bdd;

impl BddParams {
    /// Consume these `BddParams` and turn them into a raw `Bdd`.
    pub fn into_bdd(self) -> Bdd {
        self.0
    }

    pub fn as_bdd(&self) -> &Bdd {
        &self.0
    }

    pub fn cardinality(&self) -> f64 {
        self.0.cardinality()
    }
}

impl Set for BddParams {
    fn union(&self, other: &Self) -> Self {
        BddParams(self.0.or(&other.0))
    }

    fn intersect(&self, other: &Self) -> Self {
        BddParams(self.0.and(&other.0))
    }

    fn minus(&self, other: &Self) -> Self {
        BddParams(self.0.and_not(&other.0))
    }

    fn is_empty(&self) -> bool {
        self.0.is_false()
    }

    fn is_subset(&self, other: &Self) -> bool {
        // TODO: Introduce special function for this in bdd-lib to avoid allocation
        self.minus(other).is_empty()
    }
}

impl From<Bdd> for BddParams {
    fn from(val: Bdd) -> Self {
        BddParams(val)
    }
}