mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(array): add getter for reserved entry count in growable arrays
This commit is contained in:
parent
5aeb2f51a5
commit
d91c5fe916
1 changed files with 6 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ class TSGrowableArray : public TSFixedArray<T> {
|
|||
void GrowToFit(uint32_t index, int32_t zero);
|
||||
T* New(void);
|
||||
void Reserve(uint32_t count, int32_t round);
|
||||
uint32_t Reserved() const;
|
||||
uint32_t RoundToChunk(uint32_t count, uint32_t chunk);
|
||||
void SetCount(uint32_t count);
|
||||
};
|
||||
|
|
@ -112,6 +113,11 @@ void TSGrowableArray<T>::Reserve(uint32_t count, int32_t round) {
|
|||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
uint32_t TSGrowableArray<T>::Reserved() const {
|
||||
return this->m_alloc - this->m_count;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
uint32_t TSGrowableArray<T>::RoundToChunk(uint32_t count, uint32_t chunk) {
|
||||
if (count % chunk) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue