aboutsummaryrefslogtreecommitdiff
path: root/src/arraylist.c
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2024-09-06 21:10:21 +0200
committerThomas Schmucker <ts@its1.de>2024-09-06 21:10:21 +0200
commit9e8caf1e06ba7510160305da11a30d91dcfc23e5 (patch)
tree30da0c941191d0907abe829feb1bf75f0fca4b3a /src/arraylist.c
parent4ecdad9462c4447c1370cf1dd1341b2289c28566 (diff)
downloaddata-structures-9e8caf1e06ba7510160305da11a30d91dcfc23e5.tar.gz
data-structures-9e8caf1e06ba7510160305da11a30d91dcfc23e5.tar.bz2
data-structures-9e8caf1e06ba7510160305da11a30d91dcfc23e5.zip
reformat source code
Diffstat (limited to 'src/arraylist.c')
-rw-r--r--src/arraylist.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/arraylist.c b/src/arraylist.c
index 0db35ad..7a62fd4 100644
--- a/src/arraylist.c
+++ b/src/arraylist.c
@@ -11,7 +11,7 @@
11typedef int T; 11typedef int T;
12 12
13struct ArrayList { 13struct ArrayList {
14 T ** array; 14 T **array;
15 size_t size; 15 size_t size;
16 size_t capacity; 16 size_t capacity;
17}; 17};
@@ -83,7 +83,7 @@ ArrayList_growIfNeeded(struct ArrayList *arrayList)
83 } 83 }
84 else { 84 else {
85 size_t new_capacity = arrayList->capacity * 3 / 2; // *= 1.5 85 size_t new_capacity = arrayList->capacity * 3 / 2; // *= 1.5
86 T ** new_arrayList = ArrayList_allocateArray(arrayList->array, new_capacity); 86 T **new_arrayList = ArrayList_allocateArray(arrayList->array, new_capacity);
87 87
88 arrayList->capacity = new_capacity; 88 arrayList->capacity = new_capacity;
89 arrayList->array = new_arrayList; 89 arrayList->array = new_arrayList;
@@ -225,7 +225,7 @@ static int
225ArrayList_bsearchHelper(const void *ctx, const void *el) 225ArrayList_bsearchHelper(const void *ctx, const void *el)
226{ 226{
227 const struct bsearchHelper_context *context = ctx; 227 const struct bsearchHelper_context *context = ctx;
228 const const_T_ptr * element = el; 228 const const_T_ptr *element = el;
229 229
230 return context->cmp(context->key, *element, context->args); 230 return context->cmp(context->key, *element, context->args);
231} 231}
@@ -245,7 +245,7 @@ ArrayList_binarySearch(struct ArrayList *arrayList, void *key, int cmp(void *, c
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;
250 } 250 }
251 else { 251 else {