[−][src]Trait scanmut::ScanMut
Multiple insert/remove functions
Required methods
fn multi_insert<I>(&mut self, iter: I) where
I: IntoIterator<Item = (usize, T)>,
I::IntoIter: ExactSizeIterator,
I: IntoIterator<Item = (usize, T)>,
I::IntoIter: ExactSizeIterator,
Insert multiple elements at specific indices in O(n)
time.
Indices must be in monotonically non-increasing order (i.e. the next index must be smaller than or equal to the previous index).
Example
use scanmut::ScanMut; let mut v = vec![1, 2, 3, 4, 5]; v.multi_insert([(3, 8), (3, 7), (0, 6)].iter().cloned()); assert_eq!(v, vec![6, 1, 2, 3, 7, 8, 4, 5]);
Panics
Panics if
- The indices are not monotonically non-increasing.
- An index is out of bounds.
fn multi_remove<I, F>(&mut self, iter: I, sink: F) where
I: IntoIterator<Item = usize>,
F: FnMut(T),
I: IntoIterator<Item = usize>,
F: FnMut(T),
Remove multiple elements by index and calls a sink function with the removed element.
Indices must be in monotonically increasing order (i.e. the next index must be more than the previous index).
Example
use scanmut::ScanMut; let mut v = vec![1, 2, 3, 4, 5]; v.multi_remove([0, 3].iter().cloned(), drop); assert_eq!(v, vec![2, 3, 5]);
Panics
Panics if
- The indices are not monotonically increasing.
- An index is out of bounds.
Implementations on Foreign Types
impl<T> ScanMut<T> for Vec<T>
[src]
fn multi_insert<I>(&mut self, iter: I) where
I: IntoIterator<Item = (usize, T)>,
I::IntoIter: ExactSizeIterator,
[src]
I: IntoIterator<Item = (usize, T)>,
I::IntoIter: ExactSizeIterator,
fn multi_remove<I, F>(&mut self, iter: I, sink: F) where
I: IntoIterator<Item = usize>,
F: FnMut(T),
[src]
I: IntoIterator<Item = usize>,
F: FnMut(T),