SparseBinVec

Type Alias SparseBinVec 

Source
pub type SparseBinVec = SparseBinVecBase<Vec<usize>>;

Aliased Type§

pub struct SparseBinVec { /* private fields */ }

Implementations§

Source§

impl SparseBinVec

Source

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);
Source

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);
Source

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]);