Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dynamic_vectors
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PREMIERE
PROG_SEQ
dynamic_vectors
Commits
56b778db
Commit
56b778db
authored
3 years ago
by
abivarma.kandiah
Browse files
Options
Downloads
Patches
Plain Diff
Modified vector map
parent
ddd6e0f2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
header/vectors.h
+1
-1
1 addition, 1 deletion
header/vectors.h
src/test_vectors.c
+7
-4
7 additions, 4 deletions
src/test_vectors.c
src/vectors.c
+6
-3
6 additions, 3 deletions
src/vectors.c
with
14 additions
and
8 deletions
header/vectors.h
+
1
−
1
View file @
56b778db
...
@@ -30,6 +30,6 @@ void vector_insert(vector vec, type element, int index);
...
@@ -30,6 +30,6 @@ void vector_insert(vector vec, type element, int index);
void
vector_empty
(
vector
vec
);
void
vector_empty
(
vector
vec
);
void
vector_free
(
vector
vec
);
void
vector_free
(
vector
vec
);
void
vector_print
(
vector
vec
,
void
(
*
print
)(
type
));
void
vector_print
(
vector
vec
,
void
(
*
print
)(
type
));
v
oid
vector_map
(
vector
vec
,
type
(
*
f
)(
type
));
v
ector
vector_map
(
vector
vec
,
type
(
*
f
)(
type
));
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/test_vectors.c
+
7
−
4
View file @
56b778db
...
@@ -59,14 +59,17 @@ int main()
...
@@ -59,14 +59,17 @@ int main()
}
}
vector_print
(
test
,
&
print_type
);
vector_print
(
test
,
&
print_type
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
//Test Vector map
//Test Vector map
vector_map
(
test
,
&
times_two
);
vector
test_2
=
vector_map
(
test
,
&
times_two
);
vector_print
(
test
,
&
print_type
);
vector_print
(
test_2
,
&
print_type
);
//Test Vector filter
//Test Vector Free
//Test Vector Free
vector_free
(
test
);
vector_free
(
test
);
vector_free
(
test_2
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/vectors.c
+
6
−
3
View file @
56b778db
...
@@ -137,10 +137,13 @@ void vector_print(vector vec, void (*print)(type))
...
@@ -137,10 +137,13 @@ void vector_print(vector vec, void (*print)(type))
}
}
}
}
v
oid
vector_map
(
vector
vec
,
type
(
*
f
)(
type
))
v
ector
vector_map
(
vector
vec
,
type
(
*
f
)(
type
))
{
{
vector
new_vec
=
vector_create
();
for
(
int
i
=
0
;
i
<
vec
->
length
;
i
++
)
for
(
int
i
=
0
;
i
<
vec
->
length
;
i
++
)
{
{
vec
->
content
[
i
]
=
f
(
vec
->
content
[
i
]);
vec
tor_push
(
new_vec
,
f
(
vec
->
content
[
i
])
)
;
}
}
}
return
new_vec
;
\ No newline at end of file
}
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