Skip to content

Commit 9c25378

Browse files
williamfisetclaude
andauthored
Refactor GenericSegmentTree: fix formulas, add validation, expand tests (williamfiset#1251)
- Rewrite GenericSegmentTree with simplified RUF structure using 3 shared lambdas (addDelta, mulDelta, assignDelta) instead of 22 named fields - Fix incorrect productQueryAssignUpdate formula (was returning d, now correctly returns d^count) - Remove broken gcdQuerySumUpdate and productQuerySumUpdate RUFs - Throw UnsupportedOperationException for GCD+ADDITION and PRODUCT+ADDITION - Rename methods: rangeQuery1->rangeQuery, rangeUpdate1->rangeUpdate - Delete GenericSegmentTree2 (Segment-object variant) and GenericSegmentTree3 (commented-out pointer-based WIP) along with their tests and BUILD targets - Expand test coverage from 14 to 38 tests including constructor validation, single-element arrays, edge cases, negative values, overlapping updates, and randomized tests for PRODUCT and MIN/MAX+MUL combos Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 073b6c0 commit 9c25378

7 files changed

Lines changed: 1163 additions & 2077 deletions

File tree

src/main/java/com/williamfiset/algorithms/datastructures/segmenttree/BUILD

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,6 @@ java_binary(
2121
runtime_deps = [":segmenttree"],
2222
)
2323

24-
# bazel run //src/main/java/com/williamfiset/algorithms/datastructures/segmenttree:GenericSegmentTree2
25-
java_binary(
26-
name = "GenericSegmentTree2",
27-
main_class = "com.williamfiset.algorithms.datastructures.segmenttree.GenericSegmentTree2",
28-
runtime_deps = [":segmenttree"],
29-
)
30-
31-
# bazel run //src/main/java/com/williamfiset/algorithms/datastructures/segmenttree:GenericSegmentTree3
32-
java_binary(
33-
name = "GenericSegmentTree3",
34-
main_class = "com.williamfiset.algorithms.datastructures.segmenttree.GenericSegmentTree3",
35-
runtime_deps = [":segmenttree"],
36-
)
3724

3825
# bazel run //src/main/java/com/williamfiset/algorithms/datastructures/segmenttree:MaxQuerySumUpdateSegmentTree
3926
java_binary(

0 commit comments

Comments
 (0)