10 : type_(type), element_size_(type.size()), items_(array_size)
19 for (Item &item : items_) {
26 Item &item = items_[index];
27 if (item.length == item.capacity) {
28 this->realloc_to_at_least(item, item.capacity + 1);
31 void *dst =
POINTER_OFFSET(item.start, element_size_ * item.length);
39 for (
const int i :
IndexRange(values.size())) {
41 values.get(i, buffer);
42 this->
append(index, buffer);
54 mask.foreach_index([&](
const int64_t i) {
63 this->
extend(mask, virtual_values);
68 mask.foreach_index([&](
const int64_t i) {
69 Item &item = items_[i];
77 Item &item = items_[index];
83 const Item &item = items_[index];
84 return GSpan{type_, item.start, item.length};
87void GVectorArray::realloc_to_at_least(Item &item,
int64_t min_capacity)
89 const int64_t new_capacity = std::max(min_capacity, item.length * 2);
91 void *new_buffer = allocator_.
allocate(element_size_ * new_capacity, type_.
alignment());
94 item.start = new_buffer;
95 item.capacity = new_capacity;
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
#define POINTER_OFFSET(v, ofs)
void destruct_n(void *ptr, int64_t n) const
void relocate_assign_n(void *src, void *dst, int64_t n) const
void copy_construct(const void *src, void *dst) const
void destruct(void *ptr) const
int64_t alignment() const
bool is_trivially_destructible() const
static GVArray ForSpan(GSpan span)
GMutableSpan operator[](int64_t index)
void append(int64_t index, const void *value)
void extend(int64_t index, const GVArray &values)
void clear(const IndexMask &mask)
void * allocate(const int64_t size, const int64_t alignment)