pub struct CellStore { /* private fields */ }Implementations§
Source§impl CellStore
impl CellStore
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, c: CellRef) -> Option<&Cell>
Sourcepub fn get_mut(&mut self, c: CellRef) -> Option<&mut Cell>
pub fn get_mut(&mut self, c: CellRef) -> Option<&mut Cell>
Mutable access (copies the band if shared).
Sourcepub fn set(&mut self, c: CellRef, cell: Cell)
pub fn set(&mut self, c: CellRef, cell: Cell)
Stores a cell; a default (empty, unstyled) cell is removed instead.
Sourcepub fn rebuild(&mut self) -> usize
pub fn rebuild(&mut self) -> usize
Puts every cell in the band its row says and recounts the length — serialized band keys and the cached count are derived state, and the ones a file carries are not trusted. Cells outside the sheet grid are dropped; returns how many (#1008).
pub fn remove(&mut self, c: CellRef) -> Option<Cell>
Sourcepub fn iter_range(
&self,
r: RangeRef,
) -> impl Iterator<Item = (CellRef, &Cell)> + '_
pub fn iter_range( &self, r: RangeRef, ) -> impl Iterator<Item = (CellRef, &Cell)> + '_
Cells in r, row-major. Efficient for sparse data: skips empty bands and rows.
pub fn iter(&self) -> impl Iterator<Item = (CellRef, &Cell)> + '_
Sourcepub fn row(
&self,
row: u32,
c0: u32,
c1: u32,
) -> impl Iterator<Item = (u32, &Cell)> + '_
pub fn row( &self, row: u32, c0: u32, c1: u32, ) -> impl Iterator<Item = (u32, &Cell)> + '_
Cells of one row in c0..=c1.
Sourcepub fn used_range(&self) -> Option<RangeRef>
pub fn used_range(&self) -> Option<RangeRef>
Smallest range containing every stored cell, None when empty.
Sourcepub fn has(&self, c: CellRef) -> bool
pub fn has(&self, c: CellRef) -> bool
Last stored row in column col at or above below_or_at (for Ctrl+arrow navigation).
Sourcepub fn contiguous_value_run(&self, from: CellRef, cap: u32) -> Option<u32>
pub fn contiguous_value_run(&self, from: CellRef, cap: u32) -> Option<u32>
Last row (inclusive, capped at cap) of the maximal run of contiguous rows at or after
from.row that store a cell in from.col with a non-empty value in from.col. None
when from itself doesn’t qualify.
Deliberately narrower than has/get (which also count a formula with no cached value
yet, for Ctrl+arrow navigation): this matches Sheet::value_ref, whose callers test the
Value it returns with !v.is_empty() regardless of whether a formula produced it — a
formula cell with an empty cached value (="", or not yet recalculated) is “empty” to
them. A stored cell with no value and no formula (for example a formatted spill child) does
fall through to spill in value_ref, so last_contiguous_nonempty asks value_ref
about the row where this run stops.
Walks each band’s row map with BTreeMap::range (one in-order pass per band) instead of
one get per row, so a long, densely-populated run costs roughly one tree-traversal step
per row rather than one binary search per row.
Sourcepub fn diff(&self, other: &CellStore) -> Vec<CellRef>
pub fn diff(&self, other: &CellStore) -> Vec<CellRef>
Positions whose cells differ between self and other (stored on one side only, or not
equal). Bands both stores share are skipped, so comparing an edited copy with the store
it was cloned from only visits the bands the edit touched.
Sourcepub fn retained_bytes_against(&self, newer: &CellStore) -> usize
pub fn retained_bytes_against(&self, newer: &CellStore) -> usize
Approximate heap storage kept alive by this snapshot’s bands that newer no longer
shares. This is for bounding Undo history, not for reporting process memory: BTreeMap
nodes and allocator overhead vary by platform. Shared formulas and values are counted
only when the newer band no longer holds the same Arc.
Sourcepub fn take_range(&mut self, r: RangeRef) -> Vec<(CellRef, Cell)>
pub fn take_range(&mut self, r: RangeRef) -> Vec<(CellRef, Cell)>
Removes every cell in r and returns them.
Sourcepub fn shift_rows(&mut self, from: u32, delta: i64)
pub fn shift_rows(&mut self, from: u32, delta: i64)
Rows strictly greater than or equal to from moved by delta (positive = down). Rows that
would land before from… callers delete the vacated block first.