Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet_Pne
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
AlifIhsan Syauqi
Projet_Pne
Commits
c8ffa361
Commit
c8ffa361
authored
1 month ago
by
AlifIhsan Syauqi
Browse files
Options
Downloads
Patches
Plain Diff
Adjusted
parent
bb8734c3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
LES TA DES TACHES/include/list_2.h
+0
-1
0 additions, 1 deletion
LES TA DES TACHES/include/list_2.h
LES TA DES TACHES/src/list_2.c
+25
-12
25 additions, 12 deletions
LES TA DES TACHES/src/list_2.c
with
25 additions
and
13 deletions
LES TA DES TACHES/include/list_2.h
+
0
−
1
View file @
c8ffa361
#include
"list_1 (1).h"
// Gimme the number of elements of L
...
...
This diff is collapsed.
Click to expand it.
LES TA DES TACHES/src/list_2.c
+
25
−
12
View file @
c8ffa361
...
...
@@ -78,7 +78,7 @@ void ordered_insert(struct list_t * L, void * data, int (*cmp_ptrf)()){
}
}
// Elements
with data less than pivot go into
val_inf
; th
e rest
go into
val_sup.
// Elements
qui sont moins =
val_inf
et l
e rest
e
val_sup.
static
void
partition
(
list_t
*
L
,
elmlist_t
*
pivot
,
list_t
*
val_inf
,
list_t
*
val_sup
,
int
(
*
cmpFct
)(
void
*
,
void
*
))
{
for
(
elmlist_t
*
cur
=
L
->
head
;
cur
!=
NULL
;
cur
=
cur
->
suc
)
{
if
(
cmpFct
(
get_data
(
cur
),
get_data
(
pivot
))
<
0
)
...
...
@@ -92,26 +92,36 @@ void quick_sort(list_t * L, int (*cmpFct)(void*, void*)) {
assert
(
L
&&
cmpFct
);
if
(
L
->
numelm
>
1
)
{
// Remove pivot from L.
elmlist_t
*
pivot
=
get_head
(
L
);
L
->
head
=
get_suc
(
pivot
);
// Remainder of L.
L
->
head
=
get_suc
(
pivot
);
pivot
->
pred
=
NULL
;
pivot
->
suc
=
NULL
;
/** @note
* La listes des données inférieures à pivot
* La listes des données supérieures à pivot
*/
list_t
*
val_inf_pivot
=
new_list
();
list_t
*
val_sup_pivot
=
new_list
();
// Partition sur les restes de la liste
partition
(
L
,
pivot
,
val_inf_pivot
,
val_sup_pivot
,
cmpFct
);
/
/ Free the original list's elements (they have been reinserted in the new lists)
/** @note Déplacement des données de L dans val_inf_pivot et val_sup_pivot */
partition
(
L
,
pivot
,
val_inf_pivot
,
val_sup_pivot
,
cmpFct
);
/
** @note On supprimer les éléments de L sans supprimer ni L ni les jobs */
elmlist_t
*
S
;
for
(
elmlist_t
*
E
=
L
->
head
;
E
;
E
=
S
)
{
for
(
elmlist_t
*
E
=
L
->
head
;
E
;
E
=
S
){
S
=
E
->
suc
;
free
(
E
);
}
// Process elements less than pivot.
/** @note
* Si la partie inf est vide alors L commence par le pivot
* Sinon on tri grâce à cmpFct la partie inf puis on ajoute en queue le pivot
*/
if
(
is_empty
(
val_inf_pivot
))
{
L
->
head
=
pivot
;
L
->
tail
=
pivot
;
...
...
@@ -126,7 +136,10 @@ void quick_sort(list_t * L, int (*cmpFct)(void*, void*)) {
L
->
tail
=
pivot
;
L
->
numelm
+=
1
;
}
// Process elements greater than or equal to the pivot.
/** @note
* Si la partie sup n'est pas vide alors
* On la trie puis on la concatène à la partie inf
*/
if
(
!
is_empty
(
val_sup_pivot
))
{
quick_sort
(
val_sup_pivot
,
cmpFct
);
val_sup_pivot
->
head
->
pred
=
pivot
;
...
...
@@ -187,7 +200,7 @@ void quick_sort(list_t * L, int (*cmpFct)(void*, void*)) {
// View list
void
view_list
(
list_t
*
L
,
void
(
*
ptrf
)())
{
assert
(
L
&&
ptrf
);
elmlist_t
*
curr
=
L
->
head
;
...
...
@@ -197,7 +210,7 @@ void view_list(list_t * L, void (*ptrf)()) {
}
}
// Return
a
ptr
to
element
which data is key
else NULL
// Return
un
ptr
vers
element else NULL
void
find
(
list_t
*
L
,
void
**
ptrKey
,
int
(
*
cmpFct
)(),
void
(
*
delFct
)())
{
assert
(
L
&&
ptrKey
&&
cmpFct
);
elmlist_t
*
curr
=
L
->
head
;
...
...
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