Struct slow_primes::StreamingSieve [-] [+] [src]

pub struct StreamingSieve {
    // some fields omitted
}

A segmented sieve that yields only a small run of primes at a time.

This is heavily inspired by this segmented sieve code.

Methods

impl StreamingSieve

fn new(limit: usize) -> StreamingSieve

Create a new instance of the streaming sieve that will correctly progressively filter primes up to limit.

fn next(&mut self) -> Option<(usize, &BitVec)>

Extract the next chunk of filtered primes, the return value is Some((low, v)) or None if the sieve has reached the limit.

The vector stores bits for each odd number starting at low. Bit n of v is set if and only if low + 2 * n + 1 is prime.

NB. the prime 2 is not included in any of these sieves and so needs special handling.

Trait Implementations

Derived Implementations

impl Debug for StreamingSieve

fn fmt(&self, __arg_0: &mut Formatter) -> Result