14 : type_(
type), element_size_(
type.
size), items_(array_size)
20 if (type_.is_trivially_destructible) {
23 for (Item &item : items_) {
24 type_.destruct_n(item.start, item.length);
30 Item &item = items_[index];
31 if (item.length == item.capacity) {
32 this->realloc_to_at_least(item, item.capacity + 1);
35 void *dst =
POINTER_OFFSET(item.start, element_size_ * item.length);
36 type_.copy_construct(value, dst);
45 values.
get(
i, buffer);
46 this->
append(index, buffer);
47 type_.destruct(buffer);
67 this->
extend(mask, virtual_values);
73 Item &item = items_[
i];
74 type_.destruct_n(item.start, item.length);
81 Item &item = items_[index];
87 const Item &item = items_[index];
88 return GSpan{type_, item.start, item.length};
91void GVectorArray::realloc_to_at_least(Item &item,
int64_t min_capacity)
93 const int64_t new_capacity = std::max(min_capacity, item.length * 2);
95 void *new_buffer = allocator_.
allocate(element_size_ * new_capacity, type_.
alignment);
98 item.start = new_buffer;
99 item.capacity = new_capacity;
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define POINTER_OFFSET(v, ofs)
void relocate_assign_n(void *src, void *dst, int64_t n) const
const CPPType & type() const
void get(int64_t index, void *r_value) const
static GVArray from_span(GSpan span)
GMutableSpan operator[](int64_t index)
void append(int64_t index, const void *value)
const CPPType & type() const
void extend(int64_t index, const GVArray &values)
void clear(const IndexMask &mask)
void * allocate(const int64_t size, const int64_t alignment)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)