Skip to content
Snippets Groups Projects
Commit 4c90029d authored by iliya.saroukha's avatar iliya.saroukha
Browse files

feat: added comments for my api

parent 5e0a3747
Branches
No related tags found
No related merge requests found
......@@ -107,6 +107,12 @@ int64_t vec_get(vec_t *vec, size_t idx) {
return vec->data[idx];
}
/**
* @brief Function that inserts/pushes a value into an existing vector
*
* @param vec Vector in which we wish to insert a value
* @param data Value that we wish to insert
*/
void vec_push(vec_t *vec, int64_t data) {
err_init(vec);
......@@ -123,6 +129,13 @@ void vec_push(vec_t *vec, int64_t data) {
vec->len++;
}
/**
* @brief Function that inserts a value at a particular index in a given vector
*
* @param vec Vector in which we wish to insert a value
* @param data Value that we wish to insert
* @param idx Position in the vector
*/
void vec_insert_at(vec_t *vec, int64_t data, size_t idx) {
err_init(vec);
......@@ -155,6 +168,13 @@ void vec_insert_at(vec_t *vec, int64_t data, size_t idx) {
}
}
/**
* @brief Function that checks if a given value is present in a vector
*
* @param vec Vector
* @param data Value to check for
* @return `true` if value was found otherwise, `false`
*/
bool is_in_vec(vec_t *vec, int64_t data) {
if (vec == NULL) {
......@@ -171,6 +191,11 @@ bool is_in_vec(vec_t *vec, int64_t data) {
return false;
}
/**
* @brief Function that removes the last element in a vector
*
* @param vec Vector from which to pop the value
*/
void vec_pop(vec_t *vec) {
err_init(vec);
......@@ -189,6 +214,13 @@ void vec_pop(vec_t *vec) {
vec->len--;
}
/**
* @brief Function that removes a value from a vector at a particular index
* (position)
*
* @param vec Vector from which the value will be removed
* @param idx Position in the vector
*/
void vec_remove(vec_t *vec, size_t idx) {
err_init(vec);
......@@ -248,11 +280,11 @@ void vec_print(vec_t *vec) {
}
/**
* @brief Function that deallocates the memory of the vector that was passed as
* @brief Function that deallocates memory used up by the vector that was passed as
* an argument to the function. Subsequently the pointer will be set to NULL,
* that way it can be re-used safely later in the program
*
* @param vec Vector which we to destroy
* @param vec Vector which we wish to destroy
*/
void vec_destroy(vec_t **vec) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment