ObservableReasoning

Trait ObservableReasoning 

Source
pub trait ObservableReasoning<T>
where T: Observable,
{ // Required methods fn len(&self) -> usize; fn is_empty(&self) -> bool; fn get_all_items(&self) -> Vec<&T>; // Provided methods fn number_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue { ... } fn number_non_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue { ... } fn percent_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue { ... } fn percent_non_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue { ... } }
Expand description

ObservableReasoning trait provides reasoning methods for collections of Observable items.

Where T: Observable

Provides methods:

  • len() - number of items

  • is_empty() - checks if empty

  • get_all_items() - returns all items

  • number_observation() - counts items meeting threshold and effect

  • number_non_observation() - counts items not meeting criteria

  • percent_observation() - % of items meeting criteria

  • percent_non_observation() - % of items not meeting criteria

Uses T’s effect_observed() method to check criteria.

Required Methods§

Source

fn len(&self) -> usize

Source

fn is_empty(&self) -> bool

Source

fn get_all_items(&self) -> Vec<&T>

Provided Methods§

Source

fn number_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue

Counts the number of observations meeting the criteria.

Iterates through all items and filters based on:

  • item.effect_observed(target_threshold, target_effect)

Then returns the count.

Source

fn number_non_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue

Counts the number of non-observations based on the criteria.

Calculates this by:

  • self.len() - total number of items
  • minus number_observation() count

Returns the number of items not meeting criteria.

Source

fn percent_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue

Calculates the percentage of observations meeting the criteria.

Divides the number_observation count by the total number of items.

Returns value between 0.0 and 1.0 as a percentage.

Source

fn percent_non_observation( &self, target_threshold: NumericalValue, target_effect: NumericalValue, ) -> NumericalValue

Calculates the percentage of non-observations based on the criteria.

Returns 1.0 minus the percent_observation.

Implementations on Foreign Types§

Source§

impl<K, V> ObservableReasoning<V> for BTreeMap<K, V>
where K: Ord, V: Observable,

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_all_items(&self) -> Vec<&V>

Source§

impl<K, V> ObservableReasoning<V> for HashMap<K, V>
where K: Eq + Hash, V: Observable,

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_all_items(&self) -> Vec<&V>

Source§

impl<T> ObservableReasoning<T> for [T]
where T: Observable,

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_all_items(&self) -> Vec<&T>

Source§

impl<T> ObservableReasoning<T> for VecDeque<T>
where T: Observable,

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_all_items(&self) -> Vec<&T>

Source§

impl<T> ObservableReasoning<T> for Vec<T>
where T: Observable,

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn get_all_items(&self) -> Vec<&T>

Implementors§