Struct ndsparse::csl::CslLineConstructor[][src]

pub struct CslLineConstructor<'a, DS, IS, OS, const D: usize> { /* fields omitted */ }
Expand description

Constructs valid lines in a easy and interactive manner, abstracting away the complexity of the compressed sparse format.

Implementations

Jumps to the next outermost dimension, i.e., from right to left.

Example

use ndsparse::csl::{CslRef, CslVec};
let mut csl = CslVec::<i32, 3>::default();
csl
  .constructor()?
  .next_outermost_dim(3)?
  .push_line([(0, 1)].iter().copied())?
  .next_outermost_dim(4)?
  .push_line([(1, 2)].iter().copied())?
  .push_empty_line()?
  .push_line([(0, 3), (1,4)].iter().copied())?;
assert_eq!(
  csl.sub_dim(0..4),
  CslRef::new([4, 3], &[1, 2, 3, 4][..], &[0, 1, 0, 1][..], &[0, 1, 2, 2, 4][..]).ok()
);

This is the same as push_line([].iter(), [].iter()).

Example

use ndsparse::csl::{CslRef, CslVec};
let mut csl = CslVec::<i32, 3>::default();
let constructor = csl.constructor()?.next_outermost_dim(3)?;
constructor.push_empty_line()?.next_outermost_dim(2)?.push_empty_line()?;
assert_eq!(csl.line([0, 0, 0]), CslRef::new([3], &[][..], &[][..], &[0, 0][..]).ok());

Pushes a new compressed line, modifying the internal structure and if applicable, increases the current dimension length.

The iterator will be truncated to (usize::Max - last offset value + 1) or (last dimension value) and it can lead to a situation where no values will be inserted.

Arguments

  • data: Iterator of cloned items.
  • indcs: Iterator of the respective indices of each item.

Example

use ndsparse::csl::{CslRef, CslVec};
let mut csl = CslVec::<i32, 3>::default();
csl.constructor()?.next_outermost_dim(50)?.push_line([(1, 1), (40, 2)].iter().copied())?;
let line = csl.line([0, 0, 0]);
assert_eq!(line, CslRef::new([50], &[1, 2][..], &[1, 40][..], &[0, 2][..]).ok());

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.