pub struct IntervalTree { /* private fields */ }Expand description
Interval tree - manages style intervals
Uses a sorted vector with binary search for efficient interval queries. Query complexity: O(log n + k), where k is the number of overlapping intervals. Insertion complexity: O(n) (requires maintaining sort order).
Implementations§
Source§impl IntervalTree
impl IntervalTree
Sourcepub fn remove(&mut self, start: usize, end: usize, style_id: StyleId) -> bool
pub fn remove(&mut self, start: usize, end: usize, style_id: StyleId) -> bool
Remove interval that exactly matches the specified interval
Sourcepub fn query_point(&self, pos: usize) -> Vec<&Interval>
pub fn query_point(&self, pos: usize) -> Vec<&Interval>
Query all intervals containing a specific position Optimized version: uses binary search to locate interval range that may contain pos
Sourcepub fn query_range(&self, start: usize, end: usize) -> Vec<&Interval>
pub fn query_range(&self, start: usize, end: usize) -> Vec<&Interval>
Query all intervals overlapping with specified range Optimized version: uses binary search to locate interval range that may overlap
Sourcepub fn update_for_insertion(&mut self, pos: usize, delta: usize)
pub fn update_for_insertion(&mut self, pos: usize, delta: usize)
Update offsets (when text changes)
Call this method to update all intervals when inserting text of delta length at position pos
Sourcepub fn update_for_deletion(&mut self, start: usize, end: usize)
pub fn update_for_deletion(&mut self, start: usize, end: usize)
Update offsets (when text is deleted)
Call this method to update all intervals when deleting text in range [start, end)