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§

source

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.)
source

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.

source

fn shrink_to_fit(self)

Shrinks the capacity of the consign as much as possible.

source

fn collect_to_fit(self)

source

fn reserve(self, additional: usize)

Reserves capacity for at least additional more elements.

Provided Methods§

source

fn mk(self, elm: T) -> HConsed<T>

Creates a HConsed element.

Implementations on Foreign Types§

source§

impl<'a, T: Hash + Eq + Clone> HashConsign<T> for &'a RwLock<HConsign<T>>

source§

fn mk_is_new(self, elm: T) -> (HConsed<T>, bool)

If the element is already in the consign, only read access will be requested.

source§

fn collect(self)

source§

fn shrink_to_fit(self)

source§

fn collect_to_fit(self)

source§

fn reserve(self, additional: usize)

Implementors§

source§

impl<'a, T: Hash + Eq + Clone, S: BuildHasher> HashConsign<T> for &'a mut HConsign<T, S>