Skip to main content

ElementIndex

Trait ElementIndex 

Source
pub trait ElementIndex: TopologyBase {
    // Required methods
    fn element_bound(&self) -> usize;
    fn element_index(&self, element: Self::ElementId) -> usize;
}
Expand description

Dense element-index capability for topology views.

This capability maps visible element IDs to compact array indexes usable by algorithms that need visited sets, distance arrays, parent arrays, or other per-element scratch storage. The index is a property of the view, not the ID type itself: a view may expose opaque IDs while also providing a dense index mapping.

element_bound is an allocation bound, not necessarily the exact visible element count. Immutable compact layouts usually have element_bound() == element_count(). Mutable layouts with tombstones, overlays, or stable slots may have element_bound() >= element_count().

Implementations must ensure every valid visible element maps to an index less than element_bound, distinct visible elements map to distinct indexes, and indexes remain stable for the lifetime of the view operation using them.

§Performance

Methods should be O(1) unless an implementation documents a weaker contract.

Required Methods§

Source

fn element_bound(&self) -> usize

Returns the exclusive upper bound for element indexes in this view.

§Performance

Expected O(1) unless the implementation documents otherwise.

Source

fn element_index(&self, element: Self::ElementId) -> usize

Returns the dense index for element in this view.

§Performance

Expected O(1) unless the implementation documents otherwise.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§