To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... } Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize()
| 670 | // To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... } |
| 671 | // Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize() |
| 672 | int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose) |
| 673 | int GetBufSize() const { return Buf.Size; } |
| 674 | int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere |
| 675 | T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); } |