pub enum VisibleSet {
Sparse(HashSet<u32>),
Dense {
words: Box<[u64]>,
len: usize,
},
}Expand description
A set of dense node ids, represented by whichever shape the module-level rule picks at construction.
Variants§
Sparse(HashSet<u32>)
Few ids relative to the id space they live in: a hash set.
Dense
Enough ids that a bitset is no larger than the set would be.
words covers [0, words.len() * 64); an id at or past that is absent,
which is what makes the probe a bounds check rather than a branch on a
separately tracked span. len is the population count, cached because
VisibleSet::len is called on paths that cannot afford to popcount a
whole bitset.
Implementations§
Source§impl VisibleSet
impl VisibleSet
Sourcepub fn from_ids(ids: impl IntoIterator<Item = u32>) -> VisibleSet
pub fn from_ids(ids: impl IntoIterator<Item = u32>) -> VisibleSet
Collect ids and choose a representation by the module’s rule.
Duplicates are collapsed; the rule sees the distinct count.
Sourcepub fn contains(&self, id: u32) -> bool
pub fn contains(&self, id: u32) -> bool
Is id in the set?
The whole point of the type: on VisibleSet::Dense this is a bounds
check, a shift and an AND.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn iter(&self) -> impl Iterator<Item = u32> + '_
pub fn iter(&self) -> impl Iterator<Item = u32> + '_
The ids in the set, ascending on VisibleSet::Dense and in hash order
on VisibleSet::Sparse — no caller depends on the order, and every
masked path sorts or keys its own output.
Sourcepub fn intersect(&self, other: &VisibleSet) -> VisibleSet
pub fn intersect(&self, other: &VisibleSet) -> VisibleSet
The ids in both sets, with the representation re-chosen for the result.
Two dense sets intersect word-wise with no per-element allocation, which is the operation a multi-leg scope runs on every read. Any other pairing walks the smaller side and probes the larger, so the cost is set by the narrower of the two masks — and narrowing is the only thing an intersection can do.
Trait Implementations§
Source§impl Clone for VisibleSet
impl Clone for VisibleSet
Source§impl Debug for VisibleSet
impl Debug for VisibleSet
Source§impl FromIterator<u32> for VisibleSet
impl FromIterator<u32> for VisibleSet
Source§fn from_iter<I: IntoIterator<Item = u32>>(ids: I) -> VisibleSet
fn from_iter<I: IntoIterator<Item = u32>>(ids: I) -> VisibleSet
Auto Trait Implementations§
impl Freeze for VisibleSet
impl RefUnwindSafe for VisibleSet
impl Send for VisibleSet
impl Sync for VisibleSet
impl Unpin for VisibleSet
impl UnsafeUnpin for VisibleSet
impl UnwindSafe for VisibleSet
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.