dynamic_array.h v0.3.1
Reference-counted dynamic arrays for C
Loading...
Searching...
No Matches
Functions
Builder Utility

Functions for querying and accessing builder elements. More...

Functions

DA_DEF int da_builder_length (da_builder builder)
 Gets the current number of elements in the builder.
 
DA_DEF int da_builder_capacity (da_builder builder)
 Gets the current allocated capacity of the builder.
 
DA_DEF void * da_builder_get (da_builder builder, int index)
 Gets a pointer to an element at the specified index.
 
DA_DEF void da_builder_set (da_builder builder, int index, const void *element)
 Sets the value of an element at the specified index.
 

Detailed Description

Functions for querying and accessing builder elements.

Function Documentation

◆ da_builder_capacity()

DA_DEF int da_builder_capacity ( da_builder  builder)

Gets the current allocated capacity of the builder.

Parameters
builderBuilder to query (must not be NULL)
Returns
Number of elements that can be stored without reallocation

◆ da_builder_get()

DA_DEF void * da_builder_get ( da_builder  builder,
int  index 
)

Gets a pointer to an element at the specified index.

Parameters
builderBuilder to access (must not be NULL)
indexElement index (must be >= 0 and < length)
Returns
Pointer to element at index
Note
Asserts on out-of-bounds access

◆ da_builder_length()

DA_DEF int da_builder_length ( da_builder  builder)

Gets the current number of elements in the builder.

Parameters
builderBuilder to query (must not be NULL)
Returns
Number of elements currently in the builder

◆ da_builder_set()

DA_DEF void da_builder_set ( da_builder  builder,
int  index,
const void *  element 
)

Sets the value of an element at the specified index.

Parameters
builderBuilder to modify (must not be NULL)
indexElement index (must be >= 0 and < length)
elementPointer to element data to copy (must not be NULL)
Note
Asserts on out-of-bounds access or NULL parameters