1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-16 03:53:28 +01:00

ImPool: Added Reserve() helper function.

This commit is contained in:
omar 2018-09-26 21:51:30 +02:00
parent c6193d0605
commit c0a89f8f4e

View File

@ -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]; }
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 Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
};
typedef int ImPoolIdx;