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

    if indices.is_empty() || vector.is_empty() {
        return;
    }

    let mut nr_skipped_before = 0;
    vector.drain_filter(|(i, _)| {
        while nr_skipped_before < indices.len() && indices[nr_skipped_before] < *i {
            nr_skipped_before += 1;
        }

        if nr_skipped_before < indices.len() && indices[nr_skipped_before] == *i {
            true
        } else {
            *i -= nr_skipped_before;
            false
        }
    });
}
/// Reduce the size of the vector by removing values.
///
/// There is another version of this algorithm implemented on `DenseVector` for `Vec<T>`, where `T`
/// is not necessarily `Copy`.
///
/// The method operates in place.
///
/// # 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.

The method operates in place.
Reduce the size of the vector by removing values . The method operates in place .
pub(crate) fn remove_sparse_indices<T>(vector: &mut Vec<(usize, T)>, indices: &[usize]) {
    debug_assert!(indices.is_sorted());
    // All values are unique
    debug_assert!(indices.iter().collect::<HashSet<_>>().len() == indices.len());
    if indices.is_empty() || vector.is_empty() {
        return;
    }
    let mut nr_skipped_before = 0;
    vector.drain_filter(|(i, _)| {
        while nr_skipped_before < indices.len() && indices[nr_skipped_before] < *i {
            nr_skipped_before += 1;
        }
        if nr_skipped_before < indices.len() && indices[nr_skipped_before] == *i {
            true
        } else {
            *i -= nr_skipped_before;
            false
        }
    });
}
pub ( crate ) fn remove_sparse_indices < T > ( vector : & mut Vec < ( usize , T ) > , indices : & [ usize ] ) { debug_assert ! ( indices is_sorted ( ) ) ; // All values are unique debug_assert ! ( indices iter ( ) collect HashSet ( ) len ( ) indices len ( ) ) ; if indices . is_empty ( ) || vector . is_empty ( ) { return ; } let mut nr_skipped_before = 0 ; vector . drain_filter ( | ( i , _ ) | { while nr_skipped_before < indices . len ( ) && indices [ nr_skipped_before ] < * i { nr_skipped_before += 1 ; } if nr_skipped_before < indices . len ( ) && indices [ nr_skipped_before ] == * i { true } else { * i -= nr_skipped_before ; false } } ) ; }
Reduce the size of the vector by removing values.
Reduce the size of the vector by removing values .
vector
&mut Vec<(usize, T)>
indices
&[usize]
vector
&mut Vec<(usize, T)>
indices
&[usize]