-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(bdd): moved BitAnd impl into traits module
- Loading branch information
1 parent
92bbd7f
commit a6eefcd
Showing
4 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod iterators; | ||
mod traits; | ||
|
||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; | ||
use std::fmt::Debug; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::bdd::{extend_bdd_variables, Bdd}; | ||
use std::fmt::Debug; | ||
use std::ops::BitAnd; | ||
|
||
impl<TLiteral: Debug + Clone + Eq + Ord + 'static> BitAnd for Bdd<TLiteral> { | ||
type Output = Bdd<TLiteral>; | ||
|
||
fn bitand(self, rhs: Self) -> Self::Output { | ||
if self.inputs == rhs.inputs { | ||
Bdd { | ||
inputs: self.inputs.clone(), | ||
bdd: self.bdd.and(&rhs.bdd), | ||
} | ||
} else { | ||
let mut common_inputs = self.inputs.clone(); | ||
for other in &rhs.inputs { | ||
if !common_inputs.contains(other) { | ||
common_inputs.push(other.clone()); | ||
} | ||
} | ||
common_inputs.sort(); | ||
|
||
let self_lifted = extend_bdd_variables(&self, &common_inputs); | ||
let rhs_lifted = extend_bdd_variables(&rhs, &common_inputs); | ||
|
||
Bdd { | ||
inputs: common_inputs, | ||
bdd: self_lifted.bdd.and(&rhs_lifted.bdd), | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod and; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod bit; |