pub struct CumulativeHeightCache { /* private fields */ }Expand description
Prefix-sum cumulative height cache.
Stores per-row heights and lazily rebuilds a prefix-sum array whenever the heights are mutated. All lookup operations are O(log n) via binary search.
Implementations§
Source§impl CumulativeHeightCache
impl CumulativeHeightCache
Sourcepub fn set_heights(&mut self, heights: Vec<f32>)
pub fn set_heights(&mut self, heights: Vec<f32>)
Replace all row heights with heights. Marks the cache dirty.
Sourcepub fn set_uniform_height(&mut self, row_count: usize, height: f32)
pub fn set_uniform_height(&mut self, row_count: usize, height: f32)
Set row_count rows all to the same height. Marks the cache dirty.
Sourcepub fn mark_dirty(&mut self)
pub fn mark_dirty(&mut self)
Mark the cache dirty so the prefix-sum array is rebuilt on the next access.
Sourcepub fn row_at_offset(&mut self, y: f32) -> usize
pub fn row_at_offset(&mut self, y: f32) -> usize
Find the row index whose vertical span contains offset y. O(log n).
Returns 0 when the cache is empty or y < 0.
Sourcepub fn row_y_range(&mut self, row: usize) -> (f32, f32)
pub fn row_y_range(&mut self, row: usize) -> (f32, f32)
Return the (top, bottom) Y-coordinate range for row.
Sourcepub fn visible_range(
&mut self,
viewport_y: f32,
viewport_height: f32,
) -> Range<usize>
pub fn visible_range( &mut self, viewport_y: f32, viewport_height: f32, ) -> Range<usize>
Return the range of row indices at least partially visible in the viewport
[viewport_y, viewport_y + viewport_height).
Sourcepub fn total_height(&mut self) -> f32
pub fn total_height(&mut self) -> f32
Total height of all rows in logical pixels.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CumulativeHeightCache
impl RefUnwindSafe for CumulativeHeightCache
impl Send for CumulativeHeightCache
impl Sync for CumulativeHeightCache
impl Unpin for CumulativeHeightCache
impl UnsafeUnpin for CumulativeHeightCache
impl UnwindSafe for CumulativeHeightCache
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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