pub(crate) fn remove_indices<T>(vector: &mut Vec<T>, indices: &[usize]) {
    debug_assert!(indices.len() <= vector.len());
    debug_assert!(indices.is_sorted());
    // All values are unique
    debug_assert!(indices.iter().collect::<HashSet<_>>().len() == indices.len());
    debug_assert!(indices.iter().all(|&i| i < vector.len()));

    let mut i = 0;
    let mut j = 0;
    vector.retain(|_| {
        if i < indices.len() && j < indices[i] {
            j += 1;
            true
        } else if i < indices.len() { // must have j == to_remove[i]
            j += 1;
            i += 1;
            false
        } else { // i == to_remove.len()
            j += 1;
            true
        }
    });
}
/// Reduce the size of the vector by removing values.
///
/// # Arguments
///
/// * `vector`: `Vec` to remove indices from.
/// * `indices`: A set of indices to remove from the vector, assumed sorted.
Reduce the size of the vector by removing values.
Reduce the size of the vector by removing values .
pub(crate) fn remove_indices<T>(vector: &mut Vec<T>, indices: &[usize]) {
    debug_assert!(indices.len() <= vector.len());
    debug_assert!(indices.is_sorted());
    // All values are unique
    debug_assert!(indices.iter().collect::<HashSet<_>>().len() == indices.len());
    debug_assert!(indices.iter().all(|&i| i < vector.len()));
    let mut i = 0;
    let mut j = 0;
    vector.retain(|_| {
        if i < indices.len() && j < indices[i] {
            j += 1;
            true
        } else if i < indices.len() { // must have j == to_remove[i]
            j += 1;
            i += 1;
            false
        } else { // i == to_remove.len()
            j += 1;
            true
        }
    });
}
pub ( crate ) fn remove_indices < T > ( vector : & mut Vec < T > , indices : & [ usize ] ) { debug_assert ! ( indices len ( ) vector len ( ) ) ; debug_assert ! ( indices is_sorted ( ) ) ; // All values are unique debug_assert ! ( indices iter ( ) collect HashSet ( ) len ( ) indices len ( ) ) ; debug_assert ! ( indices iter ( ) all ( i i vector len ( ) ) ) ; let mut i = 0 ; let mut j = 0 ; vector . retain ( | _ | { if i < indices . len ( ) && j < indices [ i ] { j += 1 ; true } else if i < indices . len ( ) { // must have j == to_remove[i] j += 1 ; i += 1 ; false } else { // i == to_remove.len() j += 1 ; true } } ) ; }
Reduce the size of the vector by removing values.
Reduce the size of the vector by removing values .
vector
&mut Vec<T>
indices
&[usize]
vector
&mut Vec<T>
indices
&[usize]