pub struct HCTable<T>where
    T: Hash + Eq,{ /* private fields */ }
Expand description

HCTable

A table structure for efficiently managing Hc<T> instances. This struct hides the underlying table and its reference count management.

This structure utilizes a HashMap to store Hc<T> instances, offering quick retrieval and management capabilities.

Type Parameters

  • T - The type of values managed by the Hc<T> instances within this table.

Fields

  • table: HashMap - The underlying data structure storing Hc<T> instances.

Implementations§

source§

impl<T> HCTable<T>where T: Hash + Eq,

source

pub fn new() -> Self

Creates a new HCTable.

Returns

A new instance of HCTable<T>.

source

pub fn hashcons(&self, value: T) -> Hc<T>

Simplifies object retrieval or creation with an intuitive interface.

Parameters
  • value: The value to be managed.
Returns

A Hc<T> instance corresponding to the given value.

source

pub fn cleanup(&self)

Cleans up the HCTable, removing any values that are no longer in use. This method is useful for managing memory and ensuring that unused values are not unnecessarily kept in the table.

source

pub fn len(&self) -> usize

Returns the number of elements currently stored in the HCTable.

Returns

The number of elements in the HCTable.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for HCTable<T>

§

impl<T> !Send for HCTable<T>

§

impl<T> !Sync for HCTable<T>

§

impl<T> Unpin for HCTable<T>

§

impl<T> !UnwindSafe for HCTable<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.