ImBitArray: Rename ClearBits() to ClearAllBits() and add SetAllBits(). ImBitArraySetBitRange work on range [n..n2) instead of [n..n2]
diff --git a/imgui_internal.h b/imgui_internal.h
index e190833..da4e661 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -466,8 +466,9 @@
inline bool ImBitArrayTestBit(const ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; }
inline void ImBitArrayClearBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; }
inline void ImBitArraySetBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; }
-inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2)
+inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on range [n..n2)
{
+ n2--;
while (n <= n2)
{
int a_mod = (n & 31);
@@ -485,11 +486,12 @@
{
ImU32 Storage[(BITCOUNT + 31) >> 5];
ImBitArray() { }
- void ClearBits() { memset(Storage, 0, sizeof(Storage)); }
+ void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
+ void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
bool TestBit(int n) const { IM_ASSERT(n < BITCOUNT); return ImBitArrayTestBit(Storage, n); }
void SetBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArraySetBit(Storage, n); }
void ClearBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArrayClearBit(Storage, n); }
- void SetBitRange(int n1, int n2) { ImBitArraySetBitRange(Storage, n1, n2); }
+ void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2)
};
// Helper: ImBitVector
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index 482e3ac..adc0d94 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -2285,8 +2285,8 @@
g.DrawChannelsTempMergeBuffer.resize(splitter->_Count - LEADING_DRAW_CHANNELS); // Use shared temporary storage so the allocation gets amortized
ImDrawChannel* dst_tmp = g.DrawChannelsTempMergeBuffer.Data;
ImBitArray<IMGUI_TABLE_MAX_DRAW_CHANNELS> remaining_mask; // We need 132-bit of storage
- remaining_mask.ClearBits();
- remaining_mask.SetBitRange(LEADING_DRAW_CHANNELS, splitter->_Count - 1);
+ remaining_mask.ClearAllBits();
+ remaining_mask.SetBitRange(LEADING_DRAW_CHANNELS, splitter->_Count);
remaining_mask.ClearBit(table->Bg2DrawChannelUnfrozen);
IM_ASSERT(has_freeze_v == false || table->Bg2DrawChannelUnfrozen != TABLE_DRAW_CHANNEL_BG2_FROZEN);
int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS);