pub(super) struct Output<'a> {
buffer: &'a mut [f64],
len: usize,
}
impl<'a> Output<'a> {
pub(super) fn new(buffer: &'a mut [f64], capacity: usize) -> Self {
debug_assert!(
buffer.len() >= capacity,
"output buffer holds {} components but the capacity required is {capacity}",
buffer.len()
);
Output { buffer, len: 0 }
}
pub(super) fn push(&mut self, component: f64) {
if component != 0.0 {
self.buffer[self.len] = component;
self.len += 1;
}
}
pub(super) fn finish(self) -> usize {
self.len
}
}