Loading...
Searching...
No Matches
ARC_Vector

## Typedefs

typedef struct ARC_Vector | ARC_Vector
| a dynamic array type
typedef ARC_Bool(* | ARC_Vector_CompareDataFn) (void *dataA, void *dataB)
| a callback that allows the user to define a way to check the data stored in a vector for a match
typedef void(* | ARC_Vector_DestroyDataFn) (void *data)
| a callback that cleans up memory when it is removed from the vector

## Functions

void | ARC_Vector_Create (ARC_Vector **vector, ARC_Vector_CompareDataFn *compareDataFn, ARC_Vector_DestroyDataFn *destroyDataFn)
| creates an ARC_Vector which is an "expandable" array
void | ARC_Vector_Destroy (ARC_Vector *vector)
| destroys an ARC_Vector
void | ARC_Vector_Add (ARC_Vector *vector, void *data)
| adds an item to an ARC_Vector
void | ARC_Vector_Remove (ARC_Vector *vector, void *data)
| removes an item from a matching item in an ARC_Vector
void | ARC_Vector_RemoveIndex (ARC_Vector *vector, uint32_t index)
| removes an item from an ARC_Vector at an index
void | ARC_Vector_Clear (ARC_Vector *vector)
| clears all items from a vector
uint32_t | ARC_Vector_GetSize (ARC_Vector *vector)
| gets the current size of an ARC_Vector as an unsigned 32 bit integer
void * | ARC_Vector_Get (ARC_Vector *vector, uint32_t index)
| gets an item from an ARC_Vector at a position index

## Detailed Description

Additional documentation for group 'ARC_Vector'

## Typedef Documentation

## ARC_Vector

typedef struct ARC_Vector ARC_Vector

a dynamic array type

Definition at line 26 of file vector.h.

## ARC_Vector_CompareDataFn

typedef ARC_Bool(* ARC_Vector_CompareDataFn) (void *dataA, void *dataB)

a callback that allows the user to define a way to check the data stored in a vector for a match

Parameters

  [in] | dataA | the first data to check
  [in] | dataB | the second data to check

Returns
  ARC_True when dataA == dataB, and ARC_False otherwise

Definition at line 36 of file vector.h.

## ARC_Vector_DestroyDataFn

typedef void(* ARC_Vector_DestroyDataFn) (void *data)

a callback that cleans up memory when it is removed from the vector

Parameters

  [in] | data | the item to destroy

Definition at line 43 of file vector.h.

## Function Documentation

## ARC_Vector_Add()

void ARC_Vector_Add | ( | ARC_Vector * | vector,
|  | void * | data )

adds an item to an ARC_Vector

Note
  this will error if you add more than 4,294,967,295 items (the max value of an unsigned int 32)

Parameters

  [in] | vector | ARC_Vector to add to
  [in] | data | data that is being added

## ARC_Vector_Clear()

void ARC_Vector_Clear | ( | ARC_Vector * | vector | ) |

clears all items from a vector

Note
  this function will call ARC_Vector_RemoveIndex, so it's notes are also applicable to this function

Parameters

  [in] | vector | ARC_Vector to clear

## ARC_Vector_Create()

void ARC_Vector_Create | ( | ARC_Vector ** | vector,
|  | ARC_Vector_CompareDataFn * | compareDataFn,
|  | ARC_Vector_DestroyDataFn * | destroyDataFn )

creates an ARC_Vector which is an "expandable" array

Note
  for this basic implementation, the array will double in size every time the capacity is hit
  the array will also half in size when the array is only half filled

Parameters

  [out] | vector | ARC_Vector to initialize
  [in] | compareDataFn | a callback that checks if data stored in the array matches, if set to NULL and ARC_Vector_Remove is called, the pointer addresses will be compared
  [in] | destroyDataFn | a callback that frees an item on remove or clear, can be set to NULL to do nothing

## ARC_Vector_Destroy()

void ARC_Vector_Destroy | ( | ARC_Vector * | vector | ) |

destroys an ARC_Vector

Note
  this will not free the items stored in the vector
  please make sure to clear and free the children before destroying an ARC_Vector

Parameters

  [in] | vector | ARC_Vector to free

## ARC_Vector_Get()

void * ARC_Vector_Get | ( | ARC_Vector * | vector,
|  | uint32_t | index )

gets an item from an ARC_Vector at a position index

Note
  this function will error if trying to get an index that is outside the bounds of the ARC_Vector

Parameters

  [in] | vector | ARC_Vector to get data from
  [in] | index | position of data to get

Returns
  a void * item, or NULL on error

## ARC_Vector_GetSize()

uint32_t ARC_Vector_GetSize | ( | ARC_Vector * | vector | ) |

gets the current size of an ARC_Vector as an unsigned 32 bit integer

Parameters

  [in] | vector | ARC_Vector to get current size from

Returns
  the current size as a unsigned 32 bit integer

## ARC_Vector_Remove()

void ARC_Vector_Remove | ( | ARC_Vector * | vector,
|  | void * | data )

removes an item from a matching item in an ARC_Vector

Note
  this function uses the ARC_Vector_CompareDataFn that the ARC_Vector was created with
  this function will not throw an error if there is no match
  this function will call ARC_Vector_RemoveIndex, so it's notes are also applicable to this function

Parameters

  [in] | vector | ARC_Vector to remove from
  [in] | data | matching data to remove

## ARC_Vector_RemoveIndex()

void ARC_Vector_RemoveIndex | ( | ARC_Vector * | vector,
|  | uint32_t | index )

removes an item from an ARC_Vector at an index

Note
  this function will error if trying to remove an index that is outside the bounds of the ARC_Vector
  this function will use ARC_Vector_DeleteDataFn if it was set in the ARC_Vector_Create function

Parameters

  [in] | vector | ARC_Vector to remove from
  [in] | index | position of data to remove