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
impl Sieve
Sourcepub fn new(value: &str) -> Self
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])
Sourcepub fn contains(&self, value: i128) -> bool
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);
Sourcepub fn iter_value(
&self,
iterator: impl Iterator<Item = i128>,
) -> IterValue<impl Iterator<Item = i128>> ⓘ
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])
Sourcepub fn iter_state(
&self,
iterator: impl Iterator<Item = i128>,
) -> IterState<impl Iterator<Item = i128>> ⓘ
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])
Sourcepub fn iter_interval(
&self,
iterator: impl Iterator<Item = i128>,
) -> IterInterval<impl Iterator<Item = i128>> ⓘ
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more