pub struct PolynomialCache { /* private fields */ }Expand description
Thread-local polynomial computation cache
Caches expensive computations like degree, classification, and content using expression pointer hash as key. Implements true LRU eviction by tracking access times for each entry.
§Design
Uses pointer-based hashing since Expression doesn’t implement Hash.
The cache is thread-local to avoid synchronization overhead.
Implementations§
Source§impl PolynomialCache
impl PolynomialCache
Sourcepub fn with_capacity(max_entries: usize) -> Self
pub fn with_capacity(max_entries: usize) -> Self
Create a new cache with custom capacity
Sourcepub fn get_degree(&mut self, expr_hash: u64, var: &str) -> Option<i64>
pub fn get_degree(&mut self, expr_hash: u64, var: &str) -> Option<i64>
Get cached degree for expression and variable
Sourcepub fn set_degree(&mut self, expr_hash: u64, var: &str, degree: i64)
pub fn set_degree(&mut self, expr_hash: u64, var: &str, degree: i64)
Cache degree for expression and variable
Sourcepub fn get_classification(
&mut self,
expr_hash: u64,
) -> Option<CachedClassification>
pub fn get_classification( &mut self, expr_hash: u64, ) -> Option<CachedClassification>
Get cached classification for expression
Sourcepub fn set_classification(
&mut self,
expr_hash: u64,
classification: CachedClassification,
)
pub fn set_classification( &mut self, expr_hash: u64, classification: CachedClassification, )
Cache classification for expression
Sourcepub fn get_leading_coeff(&mut self, expr_hash: u64, var: &str) -> Option<u64>
pub fn get_leading_coeff(&mut self, expr_hash: u64, var: &str) -> Option<u64>
Get cached leading coefficient hash for expression and variable
Sourcepub fn set_leading_coeff(&mut self, expr_hash: u64, var: &str, coeff_hash: u64)
pub fn set_leading_coeff(&mut self, expr_hash: u64, var: &str, coeff_hash: u64)
Cache leading coefficient hash for expression and variable
Sourcepub fn get_content(&mut self, expr_hash: u64, var: &str) -> Option<u64>
pub fn get_content(&mut self, expr_hash: u64, var: &str) -> Option<u64>
Get cached content hash for expression and variable
Sourcepub fn set_content(&mut self, expr_hash: u64, var: &str, content_hash: u64)
pub fn set_content(&mut self, expr_hash: u64, var: &str, content_hash: u64)
Cache content hash for expression and variable
Sourcepub fn get_intpoly(&mut self, expr_hash: u64) -> Option<(IntPoly, Symbol)>
pub fn get_intpoly(&mut self, expr_hash: u64) -> Option<(IntPoly, Symbol)>
Get cached IntPoly for expression
Returns the cached IntPoly and variable if available. This eliminates repeated Expression → IntPoly conversions.
Sourcepub fn set_intpoly(&mut self, expr_hash: u64, poly: IntPoly, var: Symbol)
pub fn set_intpoly(&mut self, expr_hash: u64, poly: IntPoly, var: Symbol)
Cache IntPoly for expression
Caches the IntPoly representation along with its variable.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PolynomialCache
impl RefUnwindSafe for PolynomialCache
impl Send for PolynomialCache
impl Sync for PolynomialCache
impl Unpin for PolynomialCache
impl UnwindSafe for PolynomialCache
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more