pub struct BIT { /* private fields */ }
Expand description
Binary Indexed Tree (0-indexed)
This data structure supports these two queries in O(log n)
- add w to v[at]
- the sum of v[begin], v[begin+1], .., v[end-1]
Implementations§
Source§impl BIT
impl BIT
Sourcepub fn new(len: usize) -> BIT
pub fn new(len: usize) -> BIT
Constructs a new BIT of length len
.
All values are initialized zero.
§Examples
use algonium::data_structure::BIT;
let mut bit = BIT::new(100);
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the BIT.
§Examples
use algonium::data_structure::BIT;
let mut bit = BIT::new(100);
assert_eq!(bit.len(), 100);
Auto Trait Implementations§
impl Freeze for BIT
impl RefUnwindSafe for BIT
impl Send for BIT
impl Sync for BIT
impl Unpin for BIT
impl UnwindSafe for BIT
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more