pub struct Virtualized<T> { /* private fields */ }Expand description
A virtualized content container that tracks scroll state and computes visible ranges.
§Design Rationale
- Generic over item type for flexibility
- Supports both owned storage and external data sources
- Computes visible ranges for O(visible) rendering
- Optional overscan for smooth scrolling
- Momentum scrolling support
Implementations§
Source§impl<T> Virtualized<T>
impl<T> Virtualized<T>
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new virtualized container with owned storage.
§Arguments
capacity- Maximum items to retain in memory.
Sourcepub fn external(len: usize, cache_capacity: usize) -> Self
pub fn external(len: usize, cache_capacity: usize) -> Self
Create with external storage reference.
Sourcepub fn with_item_height(self, height: ItemHeight) -> Self
pub fn with_item_height(self, height: ItemHeight) -> Self
Set item height strategy.
Sourcepub fn with_fixed_height(self, height: u16) -> Self
pub fn with_fixed_height(self, height: u16) -> Self
Set fixed item height.
Sourcepub fn with_variable_heights_fenwick(
self,
default_height: u16,
capacity: usize,
) -> Self
pub fn with_variable_heights_fenwick( self, default_height: u16, capacity: usize, ) -> Self
Set variable heights with O(log n) Fenwick tree tracking.
This is more efficient than Variable(HeightCache) for large lists
as scroll-to-index mapping is O(log n) instead of O(visible).
Sourcepub fn with_overscan(self, overscan: usize) -> Self
pub fn with_overscan(self, overscan: usize) -> Self
Set overscan amount.
Sourcepub fn with_follow(self, follow: bool) -> Self
pub fn with_follow(self, follow: bool) -> Self
Enable follow mode.
Sourcepub fn scroll_offset(&self) -> usize
pub fn scroll_offset(&self) -> usize
Get current scroll offset.
Sourcepub fn visible_count(&self) -> usize
pub fn visible_count(&self) -> usize
Get current visible count (from last render).
Sourcepub fn follow_mode(&self) -> bool
pub fn follow_mode(&self) -> bool
Check if follow mode is enabled.
Sourcepub fn visible_range(&self, viewport_height: u16) -> Range<usize>
pub fn visible_range(&self, viewport_height: u16) -> Range<usize>
Calculate visible range for given viewport height.
Sourcepub fn render_range(&self, viewport_height: u16) -> Range<usize>
pub fn render_range(&self, viewport_height: u16) -> Range<usize>
Get render range with overscan for smooth scrolling.
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Scroll to bottom.
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Scroll to top.
Sourcepub fn scroll_to_start(&mut self)
pub fn scroll_to_start(&mut self)
Alias for scroll_to_top (Home key).
Sourcepub fn scroll_to_end(&mut self)
pub fn scroll_to_end(&mut self)
Scroll to bottom and enable follow mode (End key).
Sourcepub fn set_follow(&mut self, follow: bool)
pub fn set_follow(&mut self, follow: bool)
Set follow mode.
Sourcepub fn is_at_bottom(&self) -> bool
pub fn is_at_bottom(&self) -> bool
Check if scrolled to bottom.
Sourcepub fn set_visible_count(&mut self, count: usize)
pub fn set_visible_count(&mut self, count: usize)
Update visible count (called during render).
Source§impl<T> Virtualized<T>
impl<T> Virtualized<T>
Sourcepub fn get_mut(&mut self, idx: usize) -> Option<&mut T>
pub fn get_mut(&mut self, idx: usize) -> Option<&mut T>
Get mutable item by index (owned storage only).
Sourcepub fn trim_front(&mut self, max: usize) -> usize
pub fn trim_front(&mut self, max: usize) -> usize
Trim items from the front to keep at most max items (owned storage only).
Returns the number of items removed.
Sourcepub fn iter(&self) -> Box<dyn Iterator<Item = &T> + '_>
pub fn iter(&self) -> Box<dyn Iterator<Item = &T> + '_>
Iterate over items (owned storage only). Returns empty iterator for external storage.
Sourcepub fn set_external_len(&mut self, len: usize)
pub fn set_external_len(&mut self, len: usize)
Update external storage length.
Trait Implementations§
Source§impl<T: Clone> Clone for Virtualized<T>
impl<T: Clone> Clone for Virtualized<T>
Source§fn clone(&self) -> Virtualized<T>
fn clone(&self) -> Virtualized<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more