Trait SparseTensor

Source
pub trait SparseTensor<T, A: Addressable> {
    // Required methods
    fn new(address_value_map: HashMap<A, T>) -> Self;
    fn get(&self, address: &A) -> Option<&T>;
    fn get_mut(&mut self, address: &A) -> Option<&mut T>;
    fn set(&mut self, address: &A, value: T) -> Option<T>;
    fn iter(&self) -> Iter<'_, A, T>;
    fn iter_mut(&mut self) -> IterMut<'_, A, T>;
}

Required Methods§

Source

fn new(address_value_map: HashMap<A, T>) -> Self

Creates a new instance of a sparse tensor given the address-value-map

Source

fn get(&self, address: &A) -> Option<&T>

Attempts to retrieve a reference to the value at the address. Returns None if the address is outside the given bound

Source

fn get_mut(&mut self, address: &A) -> Option<&mut T>

Source

fn set(&mut self, address: &A, value: T) -> Option<T>

Attempts to reassign the value at the given index. Returns Err if the given address is out of bounds.

Source

fn iter(&self) -> Iter<'_, A, T>

Returns an Address-Value Iterator of all Address Value Pairs stored in the Sparse Tensor

Source

fn iter_mut(&mut self) -> IterMut<'_, A, T>

Returns a Mutable Address-Value Iterator of all Address Value Pairs stored in the Sparse Tensor

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§