Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
segment tree2 ’modify‘ bugfix
  • Loading branch information
smallbearrr authored and peter-jerry-ye committed Nov 28, 2024
1 parent 9dc5aee commit c66a7ee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions moonbit-docs/docs/examples/segment-tree2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ fn modify(
modify_r: Int,
tag: LazyTag
) -> Node {
if modify_l > r || l > modify_r {
if l > r {
empty_node
} else if modify_l > r || l > modify_r {
self
} else if modify_l <= l && modify_r >= r {
self.apply(tag)
} else {
guard let Node(~left, ~right, ..) = self
left.apply(tag) + right.apply(tag)
guard let Node(left~, right~, ..) = self
let mid = (l + r) >> 1
left.modify(l, mid, modify_l, modify_r, tag) +
right.modify(mid+1, r, modify_l, modify_r, tag)
}
}
```
Expand Down

0 comments on commit c66a7ee

Please sign in to comment.