Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libvector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iliya.saroukha
libvector
Commits
4c90029d
Commit
4c90029d
authored
1 year ago
by
iliya.saroukha
Browse files
Options
Downloads
Patches
Plain Diff
feat: added comments for my api
parent
5e0a3747
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
struct/vec.c
+34
-2
34 additions, 2 deletions
struct/vec.c
with
34 additions
and
2 deletions
struct/vec.c
+
34
−
2
View file @
4c90029d
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment