MCPcopy Create free account
hub / github.com/apache/datafusion / powerset_indices

Function powerset_indices

datafusion/expr/src/utils.rs:72–84  ·  view source on GitHub ↗

Internal helper that generates indices for powerset subsets using bitset iteration. Returns an iterator of index vectors, where each vector contains the indices of elements to include in that subset.

(len: usize)

Source from the content-addressed store, hash-verified

70/// Returns an iterator of index vectors, where each vector contains the indices
71/// of elements to include in that subset.
72fn powerset_indices(len: usize) -> impl Iterator<Item = Vec<usize>> {
73 (0..(1 << len)).map(move |mask| {
74 let mut indices = vec![];
75 let mut bitset = mask;
76 while bitset > 0 {
77 let rightmost: u64 = bitset & !(bitset - 1);
78 let idx = rightmost.trailing_zeros() as usize;
79 indices.push(idx);
80 bitset &= bitset - 1;
81 }
82 indices
83 })
84}
85
86/// The [power set] (or powerset) of a set S is the set of all subsets of S, \
87/// including the empty set and S itself.

Callers 1

powersetFunction · 0.85

Calls 2

mapMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…