copied set implementations from MultiFlag JS

This commit is contained in:
2026-02-09 22:11:23 +01:00
parent 80c17ac3ac
commit 140896bd7c
56 changed files with 8055 additions and 24 deletions

View File

@@ -0,0 +1,26 @@
export class BitFlagsIterator implements Iterator<number> {
private _value: number
private _current: number
public constructor(value: number) {
this._value = value
this._current = 1
}
public next(): IteratorResult<number, undefined> {
if (this._value == 0) {
return { done: true, value: undefined }
}
while ((this._value & 1) == 0) {
this._value >>= 1
this._current <<= 1
}
const result = this._current
this._value >>= 1
this._current <<= 1
return { done: false, value: result }
}
}