You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(FenwickTree): extract PrefixSumCore, correct the layout wording, harden the test attribute
Review round 6:
- Extract the descending prefix walk into a single private PrefixSumCore, now
shared by PrefixSum, RangeSumCore, and the indexer getter. The bit-strip was
written three times across two methods; centralizing it removes the drift risk.
RangeSumCore becomes the obvious PrefixSumCore(end) - PrefixSumCore(start).
- Correct the "single n-element array" wording in the XML summary, the API
reference and the README: the 1-based layout means the backing array holds
n + 1 elements with index 0 unused. The substantive claim (one flat array, no
per-node object overhead) is unchanged.
- MemoryIntensiveFactAttribute now rejects a non-positive requiredMegabytes with
ArgumentOutOfRangeException — a non-positive threshold is meaningless and would
silently force the test to run everywhere, the exact behaviour the attribute
exists to prevent — and states the no-overflow intent with checked arithmetic.
- Tag the memory-intensive regression with [Trait("Category", "MemoryIntensive")]
so CI can segregate it (a serial job, or --filter "Category!=MemoryIntensive")
without it having to be opted out of by default.
Verified: full suite 4420 passed / 0 failed; trait exclusion drops exactly that
one test (4419); the memory gate still reports Skipped under
DOTNET_GCHeapHardLimit=0x10000000.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
-`FenwickTree<T>` — a **Binary Indexed Tree** over a fixed-length numeric sequence (`where T : struct, INumber<T>`): **point update** and **prefix / range sum** both in `O(log n)`, in one `n`-element array with no per-node overhead. The prefix-sum structure the BCL lacks — running aggregates, rank / order-statistics counters, cumulative-frequency tables — where a plain array is `O(n)` per query (recompute the slice) *or*`O(n)` per update (fix the suffix). Wins precisely when updates and partial-sum queries interleave.
91
+
-`FenwickTree<T>` — a **Binary Indexed Tree** over a fixed-length numeric sequence (`where T : struct, INumber<T>`): **point update** and **prefix / range sum** both in `O(log n)`, in one flat array with no per-node overhead. The prefix-sum structure the BCL lacks — running aggregates, rank / order-statistics counters, cumulative-frequency tables — where a plain array is `O(n)` per query (recompute the slice) *or*`O(n)` per update (fix the suffix). Wins precisely when updates and partial-sum queries interleave.
0 commit comments