resize_preserving_order_with_repeated_indices

Function resize_preserving_order_with_repeated_indices 

Source
pub fn resize_preserving_order_with_repeated_indices<T>(
    vec: &[T],
    new_len: usize,
) -> (Vec<T>, Vec<usize>)
where T: Clone,
Expand description

Resize the vec while preserving the order

returns the repeated idxs

                    *     *     *     *  repeated
[0, 1, 2, 3] -> [0, 0, 1, 1, 2, 2, 3 ,3]