pub struct Sieve { /* private fields */ }
Expand description
A prime generator, using the Sieve of Eratosthenes method. This is asymptotically more efficient than the Trial Division method, but slower earlier on.
Create with let mut pset = Sieve::new()
, and then use pset.iter()
to iterate over all primes.
Implementations§
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
source§impl<P> PrimeSet for Pwhere
P: PrimeSetBasics,
impl<P> PrimeSet for Pwhere
P: PrimeSetBasics,
fn is_empty(&self) -> bool
source§fn generator(&mut self) -> PrimeSetIter<'_, Self> ⓘ
fn generator(&mut self) -> PrimeSetIter<'_, Self> ⓘ
Iterator over all primes not yet found
source§fn iter(&mut self) -> PrimeSetIter<'_, Self> ⓘ
fn iter(&mut self) -> PrimeSetIter<'_, Self> ⓘ
Iterator over all primes, starting with 2. If you don’t care about the “state” of the
PrimeSet
, this is what you want!source§fn find(&mut self, n: u64) -> (usize, u64)
fn find(&mut self, n: u64) -> (usize, u64)
Find the next largest prime from a number Read more