[−][src]Trait scanmut::ScanMut
Multiple insert/remove functions
Required methods
pub 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,
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.
pub 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),
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.
pub fn insert_all<I>(&mut self, index: usize, items: I) where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator + DoubleEndedIterator,
[src]
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator + DoubleEndedIterator,
Inserts items from an iterator at the given index.
Panics
Panics if
- The range
index..(index + items.len())
is out of bounds for thisVec
. - The iterator is shorter or longer than the reported length.
pub fn insert_all_rev<I>(&mut self, index: usize, items: I) where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
[src]
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
Inserts items in reverse from an iterator at the given index.
Panics
Panics if
- The range
index..(index + items.len())
is out of bounds for thisVec
. - The iterator is shorter or longer than the reported length.
Implementations on Foreign Types
impl<T> ScanMut<T> for Vec<T>
[src]
pub 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,
pub fn multi_remove<I, F>(&mut self, iter: I, mut sink: F) where
I: IntoIterator<Item = usize>,
F: FnMut(T),
[src]
I: IntoIterator<Item = usize>,
F: FnMut(T),
pub fn insert_all<I>(&mut self, index: usize, items: I) where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator + DoubleEndedIterator,
[src]
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator + DoubleEndedIterator,
pub fn insert_all_rev<I>(&mut self, index: usize, items: I) where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
[src]
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,