diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-09-03 15:34:14 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-09-03 15:34:38 -0400 |
| commit | d86e56089a3435990dcfa88b16805062c152d350 (patch) | |
| tree | eb9a0c7703cbd50afe2d2d22275428263c649f77 /core/container/bit_array | |
| parent | b8f8cb95823e0e56e0d8fd6ace5b38d9d57d03ff (diff) | |
Fix iteration of biased `Bit_Array`
Diffstat (limited to 'core/container/bit_array')
| -rw-r--r-- | core/container/bit_array/bit_array.odin | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/container/bit_array/bit_array.odin b/core/container/bit_array/bit_array.odin index b1149e82e..70ea6ec77 100644 --- a/core/container/bit_array/bit_array.odin +++ b/core/container/bit_array/bit_array.odin @@ -53,7 +53,7 @@ Returns: */ iterate_by_all :: proc (it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: bool) { index = it.word_idx * NUM_BITS + int(it.bit_idx) + it.array.bias - if index > it.array.max_index { return false, 0, false } + if index > it.array.max_index + it.array.bias { return false, 0, false } word := it.array.bits[it.word_idx] if len(it.array.bits) > it.word_idx else 0 set = (word >> it.bit_idx & 1) == 1 @@ -136,7 +136,7 @@ iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> it.bit_idx = 0 it.word_idx += 1 } - return index, index <= it.array.max_index + return index, index <= it.array.max_index + it.array.bias } /* Gets the state of a bit in the bit-array @@ -285,7 +285,7 @@ create :: proc(max_index: int, min_index: int = 0, allocator := context.allocato res = new(Bit_Array) res.bits = bits res.bias = min_index - res.max_index = max_index + res.max_index = max_index - min_index res.free_pointer = true return } |