Functions: add clear method to vector array

This commit is contained in:
2021-08-20 11:42:31 +02:00
parent 2b6f0cc836
commit fd51b05a02
2 changed files with 11 additions and 0 deletions

View File

@@ -82,6 +82,8 @@ class GVectorArray : NonCopyable, NonMovable {
void extend(IndexMask mask, const GVVectorArray &values);
void extend(IndexMask mask, const GVectorArray &values);
void clear(IndexMask mask);
GMutableSpan operator[](int64_t index);
GSpan operator[](int64_t index) const;

View File

@@ -78,6 +78,15 @@ void GVectorArray::extend(IndexMask mask, const GVectorArray &values)
this->extend(mask, virtual_values);
}
void GVectorArray::clear(IndexMask mask)
{
for (const int64_t i : mask) {
Item &item = items_[i];
type_.destruct_n(item.start, item.length);
item.length = 0;
}
}
GMutableSpan GVectorArray::operator[](const int64_t index)
{
Item &item = items_[index];