Skip to content

Commit

Permalink
fix: some bugs in IntervalMap
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds committed Feb 28, 2024
1 parent da15305 commit fea938b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/utils/src/interval_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ where
/// Finds all intervals in the map that overlaps with the given interval.
#[inline]
pub fn find_all_overlap(&self, interval: &Interval<T>) -> Vec<&Interval<T>> {
self.find_all_overlap_inner(self.root, interval)
if !self.nref(self.root, Node::is_sentinel) {
self.find_all_overlap_inner(self.root, interval)
} else {
Vec::new()
}
}

/// Returns a reference to the value corresponding to the key.
Expand Down Expand Up @@ -775,8 +779,8 @@ where
match self {
Entry::Occupied(entry) => entry.map_ref.nmut(entry.node, Node::value_mut),
Entry::Vacant(entry) => {
let entry_idx = NodeIndex::new(entry.map_ref.nodes.len());
let _ignore = entry.map_ref.insert(entry.interval, default);
let entry_idx = NodeIndex::new(entry.map_ref.len().wrapping_sub(1));
entry.map_ref.nmut(entry_idx, Node::value_mut)
}
}
Expand Down

0 comments on commit fea938b

Please sign in to comment.