Implemented iterating macros
This commit is contained in:
parent
c2c3c2d96e
commit
10be4dfbbf
1 changed files with 5 additions and 1 deletions
|
@ -20,8 +20,13 @@
|
||||||
#ifndef COMMON_DYNAMICARRAY_DYNAMICARRAY_H_
|
#ifndef COMMON_DYNAMICARRAY_DYNAMICARRAY_H_
|
||||||
#define 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_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);
|
typedef int (*DynamicArrayFindFunction) (void* element, void* xarg);
|
||||||
|
|
||||||
// -1 look to the left
|
// -1 look to the left
|
||||||
|
@ -31,7 +36,6 @@ typedef DynamicArrayFindFunction DynamicArrayLinearFindFunction;
|
||||||
|
|
||||||
typedef int (*DynamicArrayCloneFunction) (void* to, void* from, void* xarg);
|
typedef int (*DynamicArrayCloneFunction) (void* to, void* from, void* xarg);
|
||||||
|
|
||||||
#include "../pointers/pointers.h"
|
|
||||||
#include "../allocator-interface/allocator-interface.h"
|
#include "../allocator-interface/allocator-interface.h"
|
||||||
|
|
||||||
typedef struct DynamicArray_s {
|
typedef struct DynamicArray_s {
|
||||||
|
|
Loading…
Reference in a new issue