diff options
Diffstat (limited to 'libdimension/dimension')
-rw-r--r-- | libdimension/dimension/array.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libdimension/dimension/array.h b/libdimension/dimension/array.h index b718021..fa48ac0 100644 --- a/libdimension/dimension/array.h +++ b/libdimension/dimension/array.h @@ -170,10 +170,16 @@ dmnsn_array_remove(dmnsn_array *array, size_t i) dmnsn_array_resize(array, size - 1); } -/* Macro to shorten array iteration */ +/* Macros to shorten array iteration */ + #define DMNSN_ARRAY_FOREACH(type, i, array) \ for (type i = dmnsn_array_first(array); \ i - (type)dmnsn_array_first(array) < dmnsn_array_size(array); \ ++i) +#define DMNSN_ARRAY_FOREACH_REVERSE(type, i, array) \ + for (type i = dmnsn_array_last(array); \ + (type)dmnsn_array_last(array) - i < dmnsn_array_size(array); \ + --i) + #endif /* DIMENSION_ARRAY_H */ |