Struct lattice_qcd_rs::utils::FactorialStorageDyn
source · pub struct FactorialStorageDyn { /* private fields */ }
Expand description
Dynamical size factorial storage.
Used as a lazy cache for factorial number. This is not actually used and might be removed later.
Implementations§
source§impl FactorialStorageDyn
impl FactorialStorageDyn
sourcepub fn build_storage(&mut self, value: usize)
pub fn build_storage(&mut self, value: usize)
Build the storage up to and including value
.
#Example
let mut f = FactorialStorageDyn::new();
f.build_storage(6);
assert_eq!(*f.try_factorial(6).unwrap(), 720);
sourcepub fn factorial(&mut self, value: usize) -> u128
pub fn factorial(&mut self, value: usize) -> u128
Get the factorial number. If it is not already computed build internal storage
Panic
panic if value is greater than MAX_NUMBER_FACTORIAL
(34) in debug, overflows otherwise.
Example
let mut f = FactorialStorageDyn::new();
assert_eq!(f.factorial(6), 720);
assert_eq!(f.factorial(4), 24);
sourcepub fn try_factorial(&self, value: usize) -> Option<&u128>
pub fn try_factorial(&self, value: usize) -> Option<&u128>
try get factorial from storage
#Example
let mut f = FactorialStorageDyn::new();
assert_eq!(f.factorial(4), 24);
assert_eq!(*f.try_factorial(4).unwrap(), 24);
assert_eq!(f.try_factorial(6), None);
sourcepub fn factorial_no_storage(&self, value: usize) -> u128
pub fn factorial_no_storage(&self, value: usize) -> u128
Get factorial but does build the storage if it is missing #Example
let mut f = FactorialStorageDyn::new();
assert_eq!(f.factorial(4), 24);
assert_eq!(f.factorial_no_storage(6), 720);
assert_eq!(f.try_factorial(6), None);
Trait Implementations§
source§impl Clone for FactorialStorageDyn
impl Clone for FactorialStorageDyn
source§fn clone(&self) -> FactorialStorageDyn
fn clone(&self) -> FactorialStorageDyn
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FactorialStorageDyn
impl Debug for FactorialStorageDyn
source§impl Default for FactorialStorageDyn
impl Default for FactorialStorageDyn
source§impl Hash for FactorialStorageDyn
impl Hash for FactorialStorageDyn
source§impl PartialEq<FactorialStorageDyn> for FactorialStorageDyn
impl PartialEq<FactorialStorageDyn> for FactorialStorageDyn
source§fn eq(&self, other: &FactorialStorageDyn) -> bool
fn eq(&self, other: &FactorialStorageDyn) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for FactorialStorageDyn
impl StructuralEq for FactorialStorageDyn
impl StructuralPartialEq for FactorialStorageDyn
Auto Trait Implementations§
impl RefUnwindSafe for FactorialStorageDyn
impl Send for FactorialStorageDyn
impl Sync for FactorialStorageDyn
impl Unpin for FactorialStorageDyn
impl UnwindSafe for FactorialStorageDyn
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.