Struct DecisionTable

Source
pub struct DecisionTable { /* private fields */ }

Implementations§

Source§

impl DecisionTable

Source

pub fn new<T1, T2>(columns: T2) -> Self
where T1: Into<Domain>, T2: IntoIterator<Item = T1>,

Create a new DecisionTable with rows having specified number of input columns

Examples found in repository?
examples/wikipedia2.rs (line 17)
15fn without_dont_care_symbol() {
16  let boolean_domain = Domain::from(vec!["no", "yes"]);
17  let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain]);
18
19  table.add(Row::new(vec!["yes", "yes"], "100"));
20  table.add(Row::new(vec!["no", "yes"], "100"));
21  table.add(Row::new(vec!["yes", "no"], "011"));
22  table.add(Row::new(vec!["no", "no"], "001"));
23
24  // Complete!
25  print_completeness(&table);
26
27  table.remove(&Row::new(vec!["no", "yes"], "100"));
28
29  // Incomplete!
30  print_completeness(&table);
31}
More examples
Hide additional examples
examples/wikipedia1.rs (line 17)
15fn main() {
16  let boolean_domain = Domain::from(vec!["no", "yes"]);
17  let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain, &boolean_domain]);
18
19  table.add(Row::new(vec!["no", "yes", "no"], "01110"));
20  table.add(Row::new(vec!["no", "yes", "yes"], "00011"));
21  table.add(Row::new(vec!["no", "no", "no"], "11100"));
22  table.add(Row::new(vec!["no", "no", "yes"], "00001"));
23  table.add(Row::new(vec!["yes", "yes", "no"], "00100"));
24  table.add(Row::new(vec!["yes", "yes", "yes"], "00010"));
25  table.add(Row::new(vec!["yes", "no", "no"], "00100"));
26  table.add(Row::new(vec!["yes", "no", "yes"], "00000"));
27
28  // Complete!
29  print_completeness(&table);
30
31  table.remove(&Row::new(vec!["yes", "no", "yes"], "00000"));
32
33  // Incomplete!
34  print_completeness(&table);
35}
Source

pub fn columns_len(&self) -> usize

Source

pub fn rows_len(&self) -> usize

Source

pub fn rows<'a>(&'a self) -> impl Iterator<Item = &'a Row>

Iterate through all rows

Source

pub fn contains<'a, T>(&self, input: T) -> bool
where T: Into<&'a Vec<Cell>> + Clone,

Source

pub fn add(&mut self, row: Row)

Examples found in repository?
examples/wikipedia2.rs (line 19)
15fn without_dont_care_symbol() {
16  let boolean_domain = Domain::from(vec!["no", "yes"]);
17  let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain]);
18
19  table.add(Row::new(vec!["yes", "yes"], "100"));
20  table.add(Row::new(vec!["no", "yes"], "100"));
21  table.add(Row::new(vec!["yes", "no"], "011"));
22  table.add(Row::new(vec!["no", "no"], "001"));
23
24  // Complete!
25  print_completeness(&table);
26
27  table.remove(&Row::new(vec!["no", "yes"], "100"));
28
29  // Incomplete!
30  print_completeness(&table);
31}
More examples
Hide additional examples
examples/wikipedia1.rs (line 19)
15fn main() {
16  let boolean_domain = Domain::from(vec!["no", "yes"]);
17  let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain, &boolean_domain]);
18
19  table.add(Row::new(vec!["no", "yes", "no"], "01110"));
20  table.add(Row::new(vec!["no", "yes", "yes"], "00011"));
21  table.add(Row::new(vec!["no", "no", "no"], "11100"));
22  table.add(Row::new(vec!["no", "no", "yes"], "00001"));
23  table.add(Row::new(vec!["yes", "yes", "no"], "00100"));
24  table.add(Row::new(vec!["yes", "yes", "yes"], "00010"));
25  table.add(Row::new(vec!["yes", "no", "no"], "00100"));
26  table.add(Row::new(vec!["yes", "no", "yes"], "00000"));
27
28  // Complete!
29  print_completeness(&table);
30
31  table.remove(&Row::new(vec!["yes", "no", "yes"], "00000"));
32
33  // Incomplete!
34  print_completeness(&table);
35}
Source

pub fn remove(&mut self, row: &Row) -> bool

Returns true if the removed row existed

Examples found in repository?
examples/wikipedia2.rs (line 27)
15fn without_dont_care_symbol() {
16  let boolean_domain = Domain::from(vec!["no", "yes"]);
17  let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain]);
18
19  table.add(Row::new(vec!["yes", "yes"], "100"));
20  table.add(Row::new(vec!["no", "yes"], "100"));
21  table.add(Row::new(vec!["yes", "no"], "011"));
22  table.add(Row::new(vec!["no", "no"], "001"));
23
24  // Complete!
25  print_completeness(&table);
26
27  table.remove(&Row::new(vec!["no", "yes"], "100"));
28
29  // Incomplete!
30  print_completeness(&table);
31}
More examples
Hide additional examples
examples/wikipedia1.rs (line 31)
15fn main() {
16  let boolean_domain = Domain::from(vec!["no", "yes"]);
17  let mut table = DecisionTable::new(vec![&boolean_domain, &boolean_domain, &boolean_domain]);
18
19  table.add(Row::new(vec!["no", "yes", "no"], "01110"));
20  table.add(Row::new(vec!["no", "yes", "yes"], "00011"));
21  table.add(Row::new(vec!["no", "no", "no"], "11100"));
22  table.add(Row::new(vec!["no", "no", "yes"], "00001"));
23  table.add(Row::new(vec!["yes", "yes", "no"], "00100"));
24  table.add(Row::new(vec!["yes", "yes", "yes"], "00010"));
25  table.add(Row::new(vec!["yes", "no", "no"], "00100"));
26  table.add(Row::new(vec!["yes", "no", "yes"], "00000"));
27
28  // Complete!
29  print_completeness(&table);
30
31  table.remove(&Row::new(vec!["yes", "no", "yes"], "00000"));
32
33  // Incomplete!
34  print_completeness(&table);
35}
Source

pub fn is_complete(&self) -> bool

Returns true if the table includes every possible combination of inputs.

Examples found in repository?
examples/wikipedia1.rs (line 8)
7fn print_completeness(table: &DecisionTable) {
8  if table.is_complete() {
9    println!("Complete!");
10  } else {
11    println!("Incomplete!");
12  }
13}
More examples
Hide additional examples
examples/wikipedia2.rs (line 8)
7fn print_completeness(table: &DecisionTable) {
8  if table.is_complete() {
9    println!("Complete!");
10  } else {
11    println!("Incomplete!");
12  }
13}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.