text stringlengths 0 357 |
|---|
void dc_array_add_id(dc_array_t* array, uint32_t item) |
{ |
dc_array_add_uint(array, item); |
} |
/** |
* Add an pointer to the array. |
* After calling this function the size of the array grows by one. |
* It is okay to add the ID 0, event in this case, the array grows by one. |
* |
* @param array The array to add the item to. |
* @param item The item to add. |
* @return None. |
*/ |
void dc_array_add_ptr(dc_array_t* array, void* item) |
{ |
dc_array_add_uint(array, (uintptr_t)item); |
} |
/** |
* Find out the number of items in an array. |
* |
* @memberof dc_array_t |
* @param array The array object. |
* @return Returns the number of items in a dc_array_t object. 0 on errors or if the array is empty. |
*/ |
size_t dc_array_get_cnt(const dc_array_t* array) |
{ |
if (array==NULL || array->magic!=DC_ARRAY_MAGIC) { |
return 0; |
} |
return array->count; |
} |
/** |
* Get the item at the given index as an unsigned integer. |
* The size of the integer is always larget enough to hold a pointer. |
* |
* @memberof dc_array_t |
* @param array The array object. |
* @param index Index of the item to get. Must be between 0 and dc_array_get_cnt()-1. |
* @return Returns the item at the given index. Returns 0 on errors or if the array is empty. |
*/ |
uintptr_t dc_array_get_uint(const dc_array_t* array, size_t index) |
{ |
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count) { |
return 0; |
} |
return array->array[index]; |
} |
/** |
* Get the item at the given index as an ID. |
* |
* @memberof dc_array_t |
* @param array The array object. |
* @param index Index of the item to get. Must be between 0 and dc_array_get_cnt()-1. |
* @return Returns the item at the given index. Returns 0 on errors or if the array is empty. |
*/ |
uint32_t dc_array_get_id(const dc_array_t* array, size_t index) |
{ |
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count) { |
return 0; |
} |
if (array->type==DC_ARRAY_LOCATIONS) { |
return ((struct _dc_location*)array->array[index])->location_id; |
} |
return (uint32_t)array->array[index]; |
} |
/** |
* Get the item at the given index as an ID. |
* |
* @memberof dc_array_t |
* @param array The array object. |
* @param index Index of the item to get. Must be between 0 and dc_array_get_cnt()-1. |
* @return Returns the item at the given index. Returns 0 on errors or if the array is empty. |
*/ |
void* dc_array_get_ptr(const dc_array_t* array, size_t index) |
{ |
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count) { |
return 0; |
} |
return (void*)array->array[index]; |
} |
/** |
* Return the latitude of the item at the given index. |
* |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.