mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 04:55:13 +00:00
Add ImVector fill function
This commit is contained in:
parent
8ef7f91c93
commit
fb9ab893fa
2 changed files with 4 additions and 3 deletions
1
extern/imgui_patched/imgui.h
vendored
1
extern/imgui_patched/imgui.h
vendored
|
@ -1880,6 +1880,7 @@ struct ImVector
|
|||
inline T& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; }
|
||||
inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
|
||||
inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
||||
inline void fill(const T v) { for (int n = 0; n < Size; n++) Data[n] = v; }
|
||||
|
||||
inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > sz ? new_capacity : sz; }
|
||||
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||
|
|
6
extern/imgui_patched/imgui_internal.h
vendored
6
extern/imgui_patched/imgui_internal.h
vendored
|
@ -605,10 +605,10 @@ struct IMGUI_API ImBitVector
|
|||
ImVector<ImU32> Storage;
|
||||
int BitCount = 0;
|
||||
ImBitVector(int sz = 0) { if (sz > 0) { Create(sz); } }
|
||||
void Create(int sz) { BitCount = sz; Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
|
||||
void Create(int sz) { BitCount = sz; Storage.resize((sz + 31) >> 5); Storage.fill(0); }
|
||||
void Clear() { Storage.clear(); }
|
||||
void ClearAllBits() { IM_ASSERT(Storage.Size > 0); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
|
||||
void SetAllBits() { IM_ASSERT(Storage.Size > 0); memset(Storage.Data, 255, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
|
||||
void ClearAllBits() { Storage.fill(0); }
|
||||
void SetAllBits() { Storage.fill(~0); }
|
||||
bool TestBit(int n) const { IM_ASSERT(n >= 0 && n < BitCount); return ImBitArrayTestBit(Storage.Data, n); }
|
||||
void SetBit(int n) { IM_ASSERT(n >= 0 && n < BitCount); ImBitArraySetBit(Storage.Data, n); }
|
||||
void SetBitRange(int n, int n2) { IM_ASSERT(n >= 0 && n < BitCount && n2 > n && n2 <= BitCount); ImBitArraySetBitRange(Storage.Data, n, n2); } // Works on range [n..n2)
|
||||
|
|
Loading…
Reference in a new issue