Commit 9c25378
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
- test/java/com/williamfiset/algorithms/datastructures/segmenttree
Lines changed: 0 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 24 | | |
38 | 25 | | |
39 | 26 | | |
| |||
0 commit comments