Functions for adding elements to builders.
More...
Functions for adding elements to builders.
◆ da_builder_append()
DA_DEF void da_builder_append |
( |
da_builder |
builder, |
|
|
const void * |
element |
|
) |
| |
Appends an element to the builder.
- Parameters
-
builder | Builder to modify (must not be NULL) |
element | Pointer to element data to copy (must not be NULL) |
- Note
- Always uses doubling growth strategy for fast construction
-
Asserts on allocation failure or NULL parameters
-
Much faster than da_push() for bulk construction
int value = 42;
#define DA_BUILDER_CREATE(T)
Type-safe builder creation.
Definition dynamic_array.h:1423
DA_DEF void da_builder_append(da_builder builder, const void *element)
Appends an element to the builder.
Definition dynamic_array.h:1859
ArrayBuffer-style builder for efficient array construction.
Definition dynamic_array.h:208
◆ da_builder_append_array()
Appends all elements from an array to the builder.
- Parameters
-
builder | Builder to modify (must not be NULL) |
arr | Source array to append from (must not be NULL) |
- Note
- Automatically grows builder capacity if needed
-
Source array is unchanged
-
Arrays must have the same element_size
-
More efficient than multiple da_builder_append() calls
-
Asserts on allocation failure or mismatched element sizes
#define DA_CREATE(T, cap, retain_fn, release_fn)
Type-safe array creation.
Definition dynamic_array.h:1245
DA_DEF void da_builder_append_array(da_builder builder, da_array arr)
Appends all elements from an array to the builder.
Definition dynamic_array.h:1886
Reference-counted dynamic array structure.
Definition dynamic_array.h:192
◆ da_builder_reserve()
DA_DEF void da_builder_reserve |
( |
da_builder |
builder, |
|
|
int |
new_capacity |
|
) |
| |
Ensures the builder has at least the specified capacity.
- Parameters
-
builder | Builder to modify (must not be NULL) |
new_capacity | Minimum capacity required (must be >= 0) |
- Note
- Only increases capacity, never decreases
-
Asserts on allocation failure
-
Useful for avoiding multiple reallocations when size is known
-
Builders always use doubling growth strategy
for (int i = 0; i < 1000; i++) {
}
#define DA_BUILDER_APPEND(builder, val, T)
Type-safe element append to builder (adaptive macro)
Definition dynamic_array.h:1439
DA_DEF void da_builder_reserve(da_builder builder, int new_capacity)
Ensures the builder has at least the specified capacity.
Definition dynamic_array.h:1875