diff options
| author | Thomas Schmucker <ts@its1.de> | 2022-01-16 10:42:12 +0100 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2022-01-16 10:42:12 +0100 |
| commit | 85d7942c1c5c1b92add8a4dc70279e91b6f9cdaf (patch) | |
| tree | f9784621dbd6dcfd9faa8ca3194dfac826d8aa2a /arraylist.c | |
| parent | 2a32335f1ff91e96fd6a09819317f77d6b8bf285 (diff) | |
| parent | fb0e8a6fa561cd2a518b6a65f50e8179a19985cc (diff) | |
| download | data-structures-85d7942c1c5c1b92add8a4dc70279e91b6f9cdaf.tar.gz data-structures-85d7942c1c5c1b92add8a4dc70279e91b6f9cdaf.tar.bz2 data-structures-85d7942c1c5c1b92add8a4dc70279e91b6f9cdaf.zip | |
Merge branch 'cleanup/remove-sizeof'
Diffstat (limited to 'arraylist.c')
| -rw-r--r-- | arraylist.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/arraylist.c b/arraylist.c index cb23e94..f010d07 100644 --- a/arraylist.c +++ b/arraylist.c | |||
| @@ -115,7 +115,7 @@ ArrayList_insertAt(struct ArrayList *arrayList, size_t idx, T *ptr) | |||
| 115 | 115 | ||
| 116 | memmove(&arrayList->array[idx + 1], | 116 | memmove(&arrayList->array[idx + 1], |
| 117 | &arrayList->array[idx], | 117 | &arrayList->array[idx], |
| 118 | (arrayList->size - idx) * sizeof(arrayList->array[0])); | 118 | (arrayList->size - idx) * sizeof arrayList->array[0]); |
| 119 | arrayList->array[idx] = ptr; | 119 | arrayList->array[idx] = ptr; |
| 120 | ++arrayList->size; | 120 | ++arrayList->size; |
| 121 | } | 121 | } |
| @@ -158,7 +158,7 @@ ArrayList_removeAt(struct ArrayList *arrayList, size_t idx, void clear_func(T *, | |||
| 158 | #if defined(ARRAYLIST_KEEP_ORDER) | 158 | #if defined(ARRAYLIST_KEEP_ORDER) |
| 159 | memmove(&arrayList->arrayList[idx], | 159 | memmove(&arrayList->arrayList[idx], |
| 160 | &arrayList->arrayList[idx + 1], | 160 | &arrayList->arrayList[idx + 1], |
| 161 | (arrayList->size - (idx + 1)) * sizeof(arrayList->arrayList[0])); | 161 | (arrayList->size - (idx + 1)) * sizeof arrayList->arrayList[0]); |
| 162 | #else | 162 | #else |
| 163 | arrayList->array[idx] = arrayList->array[arrayList->size - 1]; | 163 | arrayList->array[idx] = arrayList->array[arrayList->size - 1]; |
| 164 | #endif | 164 | #endif |
| @@ -196,7 +196,7 @@ ArrayList_sort(struct ArrayList *arrayList, int cmp(const T *, const T *, void * | |||
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | // Das vollständige qsort_x()-Drama: https://stackoverflow.com/a/46042467 | 198 | // Das vollständige qsort_x()-Drama: https://stackoverflow.com/a/46042467 |
| 199 | qsort_r(arrayList->array, arrayList->size, sizeof(arrayList->array[0]), &context, ArrayList_qsortHelper); | 199 | qsort_r(arrayList->array, arrayList->size, sizeof arrayList->array[0], &context, ArrayList_qsortHelper); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | bool | 202 | bool |
| @@ -243,7 +243,7 @@ ArrayList_binarySearch(struct ArrayList *arrayList, void *key, int cmp(void *, c | |||
| 243 | .args = args | 243 | .args = args |
| 244 | }; | 244 | }; |
| 245 | 245 | ||
| 246 | T **pos = bsearch(&context, arrayList->array, arrayList->size, sizeof(arrayList->array[0]), ArrayList_bsearchHelper); | 246 | T **pos = bsearch(&context, arrayList->array, arrayList->size, sizeof arrayList->array[0], ArrayList_bsearchHelper); |
| 247 | if ( pos ) { | 247 | if ( pos ) { |
| 248 | *loc = (size_t)(pos - arrayList->array); | 248 | *loc = (size_t)(pos - arrayList->array); |
| 249 | return true; | 249 | return true; |
