Function malachite_base::slices::slice_set_zero
source · pub fn slice_set_zero<T: Zero>(xs: &mut [T])
Expand description
Sets all values in a slice to 0.
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is xs.len()
.
§Examples
use malachite_base::slices::slice_set_zero;
let mut xs = [1, 2, 3, 4, 5];
slice_set_zero::<u32>(&mut xs[1..4]);
assert_eq!(xs, [1, 0, 0, 0, 5]);
This is equivalent to mpn_zero
from mpn/generic/zero.c
, GMP 6.2.1. Note that this is needed
less often in Malachite than in GMP, since Malachite generally initializes new memory with
zeros.