Type Definition sparse_bin_mat::SparseBinVec
source · [−]pub type SparseBinVec = SparseBinVecBase<Vec<usize>>;
Implementations
sourceimpl SparseBinVec
impl SparseBinVec
sourcepub fn zeros(length: usize) -> Self
pub fn zeros(length: usize) -> Self
Creates a vector fill with zeros of the given length.
Example
let vector = SparseBinVec::zeros(3);
assert_eq!(vector.len(), 3);
assert_eq!(vector.weight(), 0);
sourcepub fn empty() -> Self
pub fn empty() -> Self
Creates an empty vector.
This allocate minimally, so it is a good placeholder.
Example
let vector = SparseBinVec::empty();
assert_eq!(vector.len(), 0);
assert_eq!(vector.weight(), 0);
sourcepub fn to_positions_vec(self) -> Vec<usize>
pub fn to_positions_vec(self) -> Vec<usize>
Converts the sparse binary vector to a Vec
of
the non trivial positions.
Example
let vector = SparseBinVec::new(3, vec![0, 2]);
assert_eq!(vector.to_positions_vec(), vec![0, 2]);