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,
impl<T> Garner<T>where
T: Unsigned,
pub fn new<M>(moduli: M, modulo: T) -> Option<Self>where
M: IntoIterator<Item = T>,
Sourcepub fn new_unchecked<M>(moduli: M, modulo: T) -> Selfwhere
M: IntoIterator<Item = T>,
pub fn new_unchecked<M>(moduli: M, modulo: T) -> Selfwhere
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 }
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> 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