Module prefix_sum::sum2d
source · Expand description
Prefix sums, but in two dimensions.
Example
use prefix_sum::sum2d::{PrefixSum2D, Rect};
let mut sum = PrefixSum2D::new(4, 4);
sum.add_rectangle(Rect::new(1, 1, 2, 2), 2);
sum.add_rectangle(Rect::new(0, 0, 2, 2), 2);
sum.add_rectangle(Rect::new(0, 2, 1, 2), 8);
assert_eq!(sum.build().into_vec(), vec![
2, 2, 0, 0,
2, 4, 2, 0,
8, 2, 2, 0,
8, 0, 0, 0,
]);
Structs
A two dimensional vector.
An iterator over the rows in a
Buf2D
.A prefix sum in two dimensional space.
A rectangle.