Skip to content

Clear discarded BitVector bits and maintain cardinality - #259

Closed
Aschenbath wants to merge 1 commit into
Yomguithereal:masterfrom
Aschenbath:fix/mnemonist-bitvector-20261121
Closed

Aschenbath wants to merge 1 commit into
Yomguithereal:masterfrom
Aschenbath:fix/mnemonist-bitvector-20261121

Conversation

@Aschenbath

Copy link
Copy Markdown

BitVector.pop(), shrinking resize(), and shrinking reallocate() leave removed bits counted in size; growing again can also resurrect their old values. Clear discarded bits and update cardinality when truncating, and clear/decrement a popped bit before it can be reused. Regrowing within the current capacity now retains that allocation as resize() documents.

Tests cover popping and reusing bits, truncation and regrowth within/across 32-bit words, truncation to zero, rank/cardinality agreement, and retained capacity.

Validation on Node 24: all 24 new regressions fail on the original source. The full Mocha suite passes (588 passing, one existing pending test), and full ESLint passes without a cache.

Prepared with OpenAI Codex assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants