PrimeBuffer

Trait PrimeBuffer 

Source
pub trait PrimeBuffer<'a> {
    type PrimeIter: Iterator<Item = &'a u64>;

    // Required methods
    fn iter(&'a self) -> Self::PrimeIter;
    fn reserve(&mut self, limit: u64);
    fn bound(&self) -> u64;
    fn contains(&self, num: u64) -> bool;
    fn clear(&mut self);
}
Expand description

This trait represents a general data structure that stores primes.

It’s recommended to store at least a bunch of small primes in the buffer to make some of the algorithms more efficient.

Required Associated Types§

Source

type PrimeIter: Iterator<Item = &'a u64>

Required Methods§

Source

fn iter(&'a self) -> Self::PrimeIter

Directly return an iterator of existing primes

Source

fn reserve(&mut self, limit: u64)

Generate primes until the largest prime in the buffer is equal or larger than limit

Source

fn bound(&self) -> u64

Get the largest primes in the list

Source

fn contains(&self, num: u64) -> bool

Test if the number is in the buffer. If a number is not in the buffer, then it’s either a composite or large than PrimeBuffer::bound()

Source

fn clear(&mut self)

clear the prime buffer to save memory

Implementors§