Function tor_circmgr::hspool::pool::random_idx_where
source ยท fn random_idx_where<R, T, P>(
rng: &mut R,
slice: &mut [T],
predicate: P
) -> Option<usize>
Available on crate feature
hs-common
only.Expand description
Helper: find a random item elt
in slice
such that predicate(elt)
is
true. Return the index of that item.
Can arbitrarily reorder slice
. This allows us to visit the indices in uniform-at-random
order, without having to do any O(N) operations or allocations.