Mercurial > public > algo-animator
comparison src/algorithms.c @ 29:dae463bbf5ca
implementing multi-thread and refactoring
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 28 Jun 2023 20:10:55 +0100 |
parents | |
children | f945bcc3571f |
comparison
equal
deleted
inserted
replaced
28:99592fae8ea1 | 29:dae463bbf5ca |
---|---|
1 #include "algorithms.h" | |
2 | |
3 | |
4 void *bubble_sort(void *arguments) { | |
5 struct AlgoArgs *args = (struct AlgoArgs *)arguments; | |
6 | |
7 printf("Size: %i\n", args->arr_size); | |
8 printf("Comparisons: %i\n", args->comparisons); | |
9 (args->comparisons)++; | |
10 printf("Comparisons: %i\n", args->comparisons); | |
11 /* | |
12 for (int i = 0; i < args->arr_size - 1; i++) { | |
13 //(*args->comparisons)++; | |
14 | |
15 for (int j = 0; j < args->arr_size - i - 1; j++) { | |
16 //(*args->comparisons)++; | |
17 | |
18 if (args->arr[j].value > args->arr[j + 1].value) { | |
19 //swap_elements(j, j + 1, args->arr); | |
20 } | |
21 | |
22 | |
23 //usleep((*args->delay)); | |
24 //bool test = false; | |
25 //delay_flow(args->delay, &test); | |
26 } | |
27 } | |
28 */ | |
29 } |