From 10be4dfbbf7fd503e4d43b9a0bd2b9c052ccc07d Mon Sep 17 00:00:00 2001 From: VegOwOtenks Date: Tue, 8 Oct 2024 10:49:32 +0200 Subject: [PATCH] Implemented iterating macros --- src/dynamicarray/dynamicarray.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dynamicarray/dynamicarray.h b/src/dynamicarray/dynamicarray.h index 3f4c889..bc77f41 100644 --- a/src/dynamicarray/dynamicarray.h +++ b/src/dynamicarray/dynamicarray.h @@ -20,8 +20,13 @@ #ifndef COMMON_DYNAMICARRAY_DYNAMICARRAY_H_ #define COMMON_DYNAMICARRAY_DYNAMICARRAY_H_ +#include "../pointers/pointers.h" + #define DYNAMICARRAY_FOREACH(da, i) for (size_t i = 0; i < (da).reserved; i++) +#define DYNAMICARRAY_ITERATE(array, type, name) for (type* name = (array).memory; name - 1 != advancep((array).memory, (array).reserved); name++) +#define DYNAMICARRAY_REVERSEITERATE(array, type, name) for (type* name = DynamicArray_GetPointer(&(array), DynamicArray_GetLength(&(array))-1); name + 1 != (array).memory ; name--) + typedef int (*DynamicArrayFindFunction) (void* element, void* xarg); // -1 look to the left @@ -31,7 +36,6 @@ typedef DynamicArrayFindFunction DynamicArrayLinearFindFunction; typedef int (*DynamicArrayCloneFunction) (void* to, void* from, void* xarg); -#include "../pointers/pointers.h" #include "../allocator-interface/allocator-interface.h" typedef struct DynamicArray_s {