Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISC 142 - Travail Pratique 011
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
florian.burgener
ISC 142 - Travail Pratique 011
Commits
e6ea047a
Commit
e6ea047a
authored
3 years ago
by
florian.burgener
Browse files
Options
Downloads
Patches
Plain Diff
Remove compare
parent
f8693ea6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
circ_list.c
+4
-4
4 additions, 4 deletions
circ_list.c
circ_list.h
+2
-2
2 additions, 2 deletions
circ_list.h
circ_list_tests.c
+3
-7
3 additions, 7 deletions
circ_list_tests.c
with
9 additions
and
13 deletions
circ_list.c
+
4
−
4
View file @
e6ea047a
...
...
@@ -62,7 +62,7 @@ element *list_insert_before(element *head, int data) {
return
list_insert_after
(
iterator
,
data
);
}
element
*
list_search
(
element
*
head
,
int
data
,
int
(
*
compare
)(
int
,
int
)
)
{
element
*
list_search
(
element
*
head
,
int
data
)
{
if
(
list_empty
(
head
))
{
return
NULL
;
}
...
...
@@ -70,7 +70,7 @@ element *list_search(element *head, int data, int (*compare)(int, int)) {
element
*
iterator
=
head
;
do
{
if
(
compare
(
iterator
->
data
,
data
)
)
{
if
(
iterator
->
data
==
data
)
{
return
iterator
;
}
...
...
@@ -81,8 +81,8 @@ element *list_search(element *head, int data, int (*compare)(int, int)) {
}
// This function cannot work when the element to be removed is the head.
element
*
list_remove
(
element
*
head
,
int
data
,
int
(
*
compare
)(
int
,
int
)
)
{
element
*
el
=
list_search
(
head
,
data
,
compare
);
element
*
list_remove
(
element
*
head
,
int
data
)
{
element
*
el
=
list_search
(
head
,
data
);
if
(
el
==
NULL
)
{
return
NULL
;
...
...
This diff is collapsed.
Click to expand it.
circ_list.h
+
2
−
2
View file @
e6ea047a
...
...
@@ -14,8 +14,8 @@ unsigned int list_count(element *head);
element
*
list_move
(
element
*
head
);
element
*
list_insert_after
(
element
*
head
,
int
data
);
element
*
list_insert_before
(
element
*
head
,
int
data
);
element
*
list_search
(
element
*
head
,
int
data
,
int
(
*
compare
)(
int
,
int
)
);
element
*
list_remove
(
element
*
head
,
int
data
,
int
(
*
compare
)(
int
,
int
)
);
element
*
list_search
(
element
*
head
,
int
data
);
element
*
list_remove
(
element
*
head
,
int
data
);
void
list_free
(
element
*
head
);
void
list_process
(
element
*
head
,
int
(
*
action
)(
int
));
...
...
This diff is collapsed.
Click to expand it.
circ_list_tests.c
+
3
−
7
View file @
e6ea047a
...
...
@@ -5,10 +5,6 @@
#include
"circ_list.h"
int
compare_equality
(
int
element
,
int
data
)
{
return
element
==
data
;
}
int
action_add_10
(
int
element
)
{
return
element
+
10
;
}
...
...
@@ -61,10 +57,10 @@ int main() {
assert
(
list_count
(
list
)
==
3
);
// list_search
element
*
search_result_1
=
list_search
(
list
,
1
,
compare_equality
);
element
*
search_result_1
=
list_search
(
list
,
1
);
assert
(
search_result_1
->
data
==
1
);
element
*
search_result_2
=
list_search
(
list
,
4
,
compare_equality
);
element
*
search_result_2
=
list_search
(
list
,
4
);
assert
(
search_result_2
==
NULL
);
// list_process
...
...
@@ -78,7 +74,7 @@ int main() {
// list_remove
printf
(
"list_remove
\n
"
);
element
*
removed_element_1
=
list_remove
(
list
,
13
,
compare_equality
);
element
*
removed_element_1
=
list_remove
(
list
,
13
);
assert
(
removed_element_1
->
data
==
13
);
assert
(
list
->
data
==
12
);
assert
(
list
->
next
->
data
==
11
);
...
...
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