Crates.io | prefix_sum |
lib.rs | prefix_sum |
version | 0.1.0 |
source | src |
created_at | 2018-12-26 19:28:33.485334 |
updated_at | 2018-12-26 19:28:33.485334 |
description | An implementation of the prefix sum data structure. |
homepage | |
repository | https://github.com/Darksonn/prefix_sum |
max_upload_size | |
id | 103930 |
size | 38,827 |
This crate provides an implementation of the prefix sum data structure.
The use case of this crate is when you want to find the result of combining a large number of interval modifications.
Example code:
use prefix_sum::PrefixSum;
let mut sum = PrefixSum::new(6);
// Each of these operations is O(1).
sum[2..4] += 2;
sum[1..3] += 3;
sum[0] += 10;
sum[3..] += 7;
// The build method is O(len).
assert_eq!(vec![10, 3, 5, 9, 7, 7], sum.build());
[dependencies]
prefix_sum = "0.1"