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 RefUnwindSafe for Sieve
impl Send for Sieve
impl Sync for Sieve
impl Unpin for Sieve
impl UnwindSafe for Sieve
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<P> PrimeSet for P where
P: PrimeSetBasics,
impl<P> PrimeSet for P where
P: PrimeSetBasics,
fn is_empty(&self) -> bool
sourcefn generator(&mut self) -> PrimeSetIter<'_, Self>ⓘNotable traits for PrimeSetIter<'a, P>impl<'a, P: PrimeSet> Iterator for PrimeSetIter<'a, P> type Item = u64;
fn generator(&mut self) -> PrimeSetIter<'_, Self>ⓘNotable traits for PrimeSetIter<'a, P>impl<'a, P: PrimeSet> Iterator for PrimeSetIter<'a, P> type Item = u64;
Iterator over all primes not yet found
sourcefn iter(&mut self) -> PrimeSetIter<'_, Self>ⓘNotable traits for PrimeSetIter<'a, P>impl<'a, P: PrimeSet> Iterator for PrimeSetIter<'a, P> type Item = u64;
fn iter(&mut self) -> PrimeSetIter<'_, Self>ⓘNotable traits for PrimeSetIter<'a, P>impl<'a, P: PrimeSet> Iterator for PrimeSetIter<'a, P> type Item = u64;
Iterator over all primes, starting with 2. If you don’t care about the “state” of the
PrimeSet, this is what you want! Read more
sourcefn find_vec(&self, n: u64) -> Option<(usize, u64)>
fn find_vec(&self, n: u64) -> Option<(usize, u64)>
Find the next largest prime from a number, if it is within the already-found list Read more
sourcefn prime_factors(&mut self, n: u64) -> Vec<u64>
fn prime_factors(&mut self, n: u64) -> Vec<u64>
Get the prime factors of a number, starting from 2, including repeats
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more