[][src]Type Definition sparse_bin_mat::SparseBinVec

type SparseBinVec = SparseBinVecBase<Vec<usize>>;

Implementations

impl SparseBinVec[src]

pub fn new(length: usize, positions: Vec<usize>) -> Self[src]

Creates a new vector with the given length and list of non trivial positions.

Example

let vector = SparseBinVec::new(5, vec![0, 2]);

assert_eq!(vector.len(), 5);
assert_eq!(vector.weight(), 2);

Panic

Panics if a position is greater or equal to the length.

This example panics
let vector = SparseBinVec::new(2, vec![1, 3]);

pub fn zeros(length: usize) -> Self[src]

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

pub fn empty() -> Self[src]

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

pub fn to_positions_vec(self) -> Vec<usize>[src]

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