pub trait SparseVector<T, I>: Clone + IntoIterator<Item = (T, I)> {
Show 13 methods
// Required methods
fn new() -> Self;
fn unsafe_insert(&mut self, index: I, value: T);
fn add_or_insert(&mut self, index: I, value: T);
fn get(&self, index: &I) -> T;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn mul_by(&mut self, factor: T);
fn mul_element_by(&mut self, index: I, factor: T);
fn trim(&mut self, cutoff: T);
fn retain(&mut self, f: impl FnMut(&(T, I)) -> bool);
fn normalize(&mut self);
fn iter<'a>(&'a self) -> impl Iterator<Item = &'a (T, I)>
where T: 'a,
I: 'a;
// Provided method
fn reserve(&mut self, _additional: usize) { ... }
}Expand description
A sparse vector keyed by index type I with values of type T.
Used by GeneralizedTableau to
store the coefficient over each branching bitstring. The default
implementation is Vec<(T, I)>; alternative backings (BTreeMap,
HashMap, etc.) can be provided by downstream code.
Required Methods§
Sourcefn unsafe_insert(&mut self, index: I, value: T)
fn unsafe_insert(&mut self, index: I, value: T)
Inserts an element without checking whether the index already exists.
Sourcefn add_or_insert(&mut self, index: I, value: T)
fn add_or_insert(&mut self, index: I, value: T)
Add value into the entry at index, creating it if absent.
Sourcefn mul_element_by(&mut self, index: I, factor: T)
fn mul_element_by(&mut self, index: I, factor: T)
Multiply the value at index by factor. No-op if absent.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".