pub struct TableIndex { /* private fields */ }Expand description
Memoised sort-and-filter index to avoid recomputing expensive permutations on every frame.
The dirty flags track whether the cached index is still valid. Call
TableIndex::invalidate_sort after a sort-order change and
TableIndex::invalidate_filter after a filter change (sorting a different
column also implicitly invalidates the filter index).
Implementations§
Source§impl TableIndex
impl TableIndex
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty (dirty) TableIndex.
Sourcepub fn invalidate_sort(&mut self)
pub fn invalidate_sort(&mut self)
Mark the sort index (and consequently the filter index) as stale.
Sourcepub fn invalidate_filter(&mut self)
pub fn invalidate_filter(&mut self)
Mark only the filter index as stale (sort order is unchanged).
Sourcepub fn is_sort_dirty(&self) -> bool
pub fn is_sort_dirty(&self) -> bool
Returns true if the sort index needs to be recomputed.
Sourcepub fn is_filter_dirty(&self) -> bool
pub fn is_filter_dirty(&self) -> bool
Returns true if the filter index needs to be recomputed.
Sourcepub fn sort_index(
&mut self,
rows: &dyn RowSource,
sort: &HeaderSortState,
) -> &[usize]
pub fn sort_index( &mut self, rows: &dyn RowSource, sort: &HeaderSortState, ) -> &[usize]
Return the current sort index, recomputing it if dirty.
The returned slice holds row indices in sorted order.
Sourcepub fn filter_index(
&mut self,
rows: &dyn RowSource,
sort: &HeaderSortState,
filters: &[ColumnFilter],
) -> &[usize]
pub fn filter_index( &mut self, rows: &dyn RowSource, sort: &HeaderSortState, filters: &[ColumnFilter], ) -> &[usize]
Return the current filter index, recomputing it if dirty.
The returned slice holds a subset of the sort index that passes every active column filter.
Trait Implementations§
Source§impl Clone for TableIndex
impl Clone for TableIndex
Source§fn clone(&self) -> TableIndex
fn clone(&self) -> TableIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableIndex
impl Debug for TableIndex
Auto Trait Implementations§
impl Freeze for TableIndex
impl RefUnwindSafe for TableIndex
impl Send for TableIndex
impl Sync for TableIndex
impl Unpin for TableIndex
impl UnsafeUnpin for TableIndex
impl UnwindSafe for TableIndex
Blanket Implementations§
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more