Garner

Struct Garner 

Source
pub struct Garner<T>
where T: Unsigned,
{ /* private fields */ }
Expand description

Garner’s algorithm with precomputation for fixed moduli.

Implementations§

Source§

impl<T> Garner<T>
where T: Unsigned,

Source

pub fn new<M>(moduli: M, modulo: T) -> Option<Self>
where M: IntoIterator<Item = T>,

Source

pub fn new_unchecked<M>(moduli: M, modulo: T) -> Self
where M: IntoIterator<Item = T>,

Examples found in repository?
crates/competitive/src/math/garner.rs (line 36)
17    pub fn new<M>(moduli: M, modulo: T) -> Option<Self>
18    where
19        M: IntoIterator<Item = T>,
20    {
21        if modulo == T::zero() {
22            return None;
23        }
24        let moduli: Vec<_> = moduli.into_iter().collect();
25        if moduli.iter().any(|&m| m.is_zero()) {
26            return None;
27        }
28        let n = moduli.len();
29        for i in 0..n {
30            for j in 0..i {
31                if moduli[i].gcd(moduli[j]) != T::one() {
32                    return None;
33                }
34            }
35        }
36        Some(Self::new_unchecked(moduli, modulo))
37    }
Source

pub fn solve<B, I>(&self, residues: B) -> Option<T>
where B: IntoIterator<Item = T, IntoIter = I>, I: ExactSizeIterator<Item = T>,

Auto Trait Implementations§

§

impl<T> Freeze for Garner<T>

§

impl<T> RefUnwindSafe for Garner<T>
where T: RefUnwindSafe,

§

impl<T> Send for Garner<T>
where T: Send,

§

impl<T> Sync for Garner<T>
where T: Sync,

§

impl<T> Unpin for Garner<T>
where T: Unpin,

§

impl<T> UnwindSafe for Garner<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.