Commit Graph

10 Commits

Author SHA1 Message Date
Eugene 594ec641a4 refactor(bitmap): switch to mutating API and return `this` from all setters
The Bitmap API is now fully mutating:
- all state-changing methods (`set`, `remove`, `grow`, `clear`, `filter`) return `this`
- bitwise operations (`and`, `or`, `xor`, `andNot`) no longer clone internally and now mutate the current bitmap
- functional (immutable-style) usage is still possible via explicit `.clone()`
- removed implicit cloning from all arithmetic operations

This change makes the mutation semantics consistent and predictable, while keeping optional immutability available through manual cloning.
2025-12-10 16:01:04 +03:00
Eugene b23eb4d7c0 add spaces between bits group 2025-12-06 12:30:06 +03:00
Eugene 02e69826dd add serialization/deserialization/debug methods (toString/fromString) 2025-12-06 12:23:50 +03:00
Eugene 5667aef80f docs(bitmap): add JSDoc for Bitmap class and helper functions
Add comprehensive JSDoc comments to src/bitmap.ts covering:
- private helper functions (computeBitsArrayLength, getBitPositionIndex, getBitPosition, getMask)
- the Bitmap class and all public methods (constructor, iterator, grow, set, remove, contains, count, and, andNot, or, xor, range, filter, clear, clone, min, max, minZero, maxZero)

Comments describe parameters, return values and behavior (including iteration semantics). No runtime behaviour changes — this improves editor/tooling support (autocomplete/type hints) and prepares the code for TypeDoc generation.
2025-12-01 22:45:36 +03:00
Eugene f840742724 fix(bitmap): correct growth at byte boundaries, add explicit bounds checks, and adjust bitwise ops
- grow now accounts for bit index + 1 when computing required byte length to avoid off-by-one at byte boundaries
- contains/remove use explicit bounds checks (idx >= this.bits.length) instead of relying on truthy checks
- and clears tail bytes not covered by the shorter operand
- or/xor expand the result to encompass a longer operand so all bits are preserved
- update behavior to be more predictable and safer; tests pass
2025-12-01 21:58:51 +03:00
Eugene eec57ec719 removed useless interface 2025-12-01 19:26:25 +03:00
Eugene e5dd13477b add simple iterators 2025-12-01 17:30:15 +03:00
Eugene ea844221b7 Little DX upgrade. Now .range() can return VOID.
It means that user don't need to always return `true` to continue iteration, but user can break the iterations by returning `false`.
2025-04-03 19:18:00 +03:00
Eugene dd78397385 Fixed bug with 0-size bitmap (.grow(x))
Add testcase
Add tests script & config
2025-04-02 09:08:46 +03:00
= 0368f12d60 init commit 2024-07-04 22:34:19 +03:00