mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-23 16:16:36 +00:00
ImPool: Added Reserve() helper function.
This commit is contained in:
parent
c6193d0605
commit
c0a89f8f4e
@ -241,6 +241,7 @@ struct IMGUI_API ImPool
|
|||||||
T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
|
T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
|
||||||
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
||||||
void Remove(ImGuiID key, int idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
void Remove(ImGuiID key, int idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
||||||
|
void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
|
||||||
};
|
};
|
||||||
typedef int ImPoolIdx;
|
typedef int ImPoolIdx;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user