Trait hashconsing::HashConsign
source · pub trait HashConsign<T: Hash>: Sized {
// Required methods
fn mk_is_new(self, elm: T) -> (HConsed<T>, bool);
fn collect(self);
fn shrink_to_fit(self);
fn collect_to_fit(self);
fn reserve(self, additional: usize);
// Provided method
fn mk(self, elm: T) -> HConsed<T> { ... }
}
Expand description
HConsed element creation.
Implemented via a trait to be able to extend RwLock
for lazy static
consigns.
Required Methods§
sourcefn mk_is_new(self, elm: T) -> (HConsed<T>, bool)
fn mk_is_new(self, elm: T) -> (HConsed<T>, bool)
Hashconses something and returns the hash consed version.
Returns true
iff the element
- was not in the consign at all, or
- was in the consign but it is not referenced (weak ref cannot be upgraded.)
sourcefn collect(self)
fn collect(self)
Removes dead elements from the consign.
An element is dead if it is not being referenced outside of the consign, meaning it is not reachable anymore.
sourcefn shrink_to_fit(self)
fn shrink_to_fit(self)
Shrinks the capacity of the consign as much as possible.
sourcefn collect_to_fit(self)
fn collect_to_fit(self)
Calls collect
and shrink_to_fit
.