AlgaeSet

Struct AlgaeSet 

Source
pub struct AlgaeSet<E> { /* private fields */ }
Expand description

A representation of a ZF set.

All elements must belong to a “supertype” E. Subsets of the supertype are determined by a given set of conditions (similar to the conditions used in the set construction paradigm of traditional ZF set theory).

Element existence (ie. whether or not a certain element is a member of a given set) is given through the has function. Set unions are given by the or function, and set intersections are given by the and function.

§Examples

use algae_rs::algaeset::AlgaeSet;

let mut pos_floats = AlgaeSet::new(vec![
    Box::new(|e: f32| e > 0_f32)
]);

assert!(pos_floats.has(12_f32));

let neg_floats = AlgaeSet::new(vec![
    Box::new(|e: f32| e < 0_f32)
]);

pos_floats.or(neg_floats);
let all_floats = pos_floats;
assert!(all_floats.has(12_f32));
assert!(all_floats.has(-12_f32));

Implementations§

Source§

impl<E> AlgaeSet<E>

Source

pub fn new(pos_conditions: Vec<Box<dyn Fn(E) -> bool>>) -> Self

Returns an AlgaeSet defined by a Vec of conditions

Source

pub fn mono(condition: Box<dyn Fn(E) -> bool>) -> Self

Returns an AlgaeSet defined by a single condition

Source

pub fn all() -> Self

Returns an AlgaeSet containing all members of the type E

Source§

impl<E: Copy + Clone> AlgaeSet<E>

Source

pub fn has(&self, element: E) -> bool

Returns whether or not element is in the given set

Source§

impl<E: PartialEq + Copy + Clone + 'static> AlgaeSet<E>

Source

pub fn add(&mut self, element: E)

Adds element to the given set

Source

pub fn remove(&mut self, element: E)

Removes element from the given set

Source

pub fn or(&mut self, other: Self)

Adds all elements from other to self

Source

pub fn and(&mut self, other: Self)

Removes all elements from self that aren’t in other

Auto Trait Implementations§

§

impl<E> Freeze for AlgaeSet<E>

§

impl<E> !RefUnwindSafe for AlgaeSet<E>

§

impl<E> !Send for AlgaeSet<E>

§

impl<E> !Sync for AlgaeSet<E>

§

impl<E> Unpin for AlgaeSet<E>

§

impl<E> !UnwindSafe for AlgaeSet<E>

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.