Skip to content

Commit 26ba6a7

Browse files
marius-bughiuclaude
andcommitted
docs(CompressedIntSet): say four bytes of *payload* for a fresh-chunk range add
Addresses round 7 of the Copilot review on #337 (one point, on two doc surfaces). "A range in a fresh chunk is four bytes, whatever its width" described the run pair's payload, not its heap cost — the pair lives in a ushort[], which carries an array header. Both surfaces now say "four bytes of payload" and note the header, matching how MemoryUsageInBytes already documents its own exclusion. The claim the sentence exists to make — that the cost is independent of the range's width — is unchanged and still true. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1527583 commit 26ba6a7

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

docs/api/collections.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,8 @@ CompressedIntSet(IEnumerable<int> source)
22242224
- `bool TryAdd(int item)` — `true` if added, `false` if already present.
22252225
- `long AddRange(int start, int endInclusive)` — adds every value in the inclusive range and
22262226
returns how many were **new**. A range landing in a chunk the set does not yet touch is stored as
2227-
a **single run pairfour bytes, whatever the range's width** — so this is the cheap way to
2227+
a **single run pairfour bytes of payload, whatever the range's width** (plus the array header,
2228+
which `MemoryUsageInBytes` excludes too) — so this is the cheap way to
22282229
build a clustered set. Throws `ArgumentOutOfRangeException` if `endInclusive < start`.
22292230
- `bool Contains(int item)` — `O(1)` in a bitmap chunk, `O(log n)` in an array or run chunk, and a
22302231
single comparison against the chunk index when nothing covers the value.

src/Celerity/Collections/CompressedIntSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ public bool TryAdd(int item)
243243
/// <returns>The number of values the call actually added (values already present are not counted).</returns>
244244
/// <remarks>
245245
/// A range that lands in a chunk the set does not yet touch is stored as a single run pair —
246-
/// four bytes, whatever the range's width — which is why this is the cheap way to build a
246+
/// four bytes of payload, whatever the range's width (plus the array header, which
247+
/// <see cref="MemoryUsageInBytes"/> excludes too) — which is why this is the cheap way to build a
247248
/// clustered set. A range overlapping an existing chunk merges into it and the chunk is left in
248249
/// its natural form; call <see cref="Optimize"/> afterwards to re-compress those.
249250
/// </remarks>

0 commit comments

Comments
 (0)