Struct xensieve::Sieve

source ·
pub struct Sieve { /* private fields */ }
Expand description

The representation of a Xenakis Sieve, constructed from a string notation of one or more Residual classes combined with logical operators. This Rust implementation follows the Python implementation in Ariza (2005), with significant performance and interface enhancements: https://direct.mit.edu/comj/article/29/2/40/93957

Implementations§

source§

impl Sieve

source

pub fn new(value: &str) -> Self

Construct a Xenakis Sieve from a string representation.

let s = xensieve::Sieve::new("3@0|5@1");
assert_eq!(s.iter_value(0..15).collect::<Vec<_>>(), vec![0, 1, 3, 6, 9, 11, 12])
source

pub fn contains(&self, value: i128) -> bool

Return true if the value is contained with this Sieve.

let s = xensieve::Sieve::new("3@0 & 5@0");
assert_eq!(s.contains(15), true);
assert_eq!(s.contains(16), false);
assert_eq!(s.contains(30), true);
source

pub fn iter_value( &self, iterator: impl Iterator<Item = i128> ) -> IterValue<impl Iterator<Item = i128>>

For the iterator provided as an input, iterate the subset of values that are contained within the sieve.

let s = xensieve::Sieve::new("3@0|4@0");
assert_eq!(s.iter_value(0..=12).collect::<Vec<_>>(), vec![0, 3, 4, 6, 8, 9, 12])
source

pub fn iter_state( &self, iterator: impl Iterator<Item = i128> ) -> IterState<impl Iterator<Item = i128>>

For the iterator provided as an input, iterate the Boolean status of contained.

let s = xensieve::Sieve::new("3@0|4@0");
assert_eq!(s.iter_state(0..=6).collect::<Vec<_>>(), vec![true, false, false, true, true, false, true])
source

pub fn iter_interval( &self, iterator: impl Iterator<Item = i128> ) -> IterInterval<impl Iterator<Item = i128>>

Iterate over integer intervals between values in the sieve.

let s = xensieve::Sieve::new("3@0|4@0");
assert_eq!(s.iter_interval(0..=12).collect::<Vec<_>>(), vec![3, 1, 2, 2, 1, 3])

Trait Implementations§

source§

impl BitAnd for &Sieve

§

type Output = Sieve

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd for Sieve

§

type Output = Sieve

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl BitOr for &Sieve

§

type Output = Sieve

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl BitOr for Sieve

§

type Output = Sieve

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl BitXor for &Sieve

§

type Output = Sieve

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
source§

impl BitXor for Sieve

§

type Output = Sieve

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
source§

impl Clone for Sieve

source§

fn clone(&self) -> Sieve

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Sieve

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Sieve

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Not for &Sieve

§

type Output = Sieve

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl Not for Sieve

§

type Output = Sieve

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more

Auto Trait Implementations§

§

impl Freeze for Sieve

§

impl RefUnwindSafe for Sieve

§

impl Send for Sieve

§

impl Sync for Sieve

§

impl Unpin for Sieve

§

impl UnwindSafe for Sieve

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.