| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-07 09:50:34 +02:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup bli | 
					
						
							|  |  |  |  * \brief Generic array manipulation API. | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | #include "BLI_compiler_typecheck.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-06 16:45:06 +01:00
										 |  |  | #include "BLI_sys_types.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 15:04:53 +01:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | void _bli_array_reverse(void *arr, unsigned int arr_len, size_t arr_stride); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #define BLI_array_reverse(arr, arr_len) _bli_array_reverse(arr, arr_len, sizeof(*(arr)))
 | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | void _bli_array_wrap(void *arr, unsigned int arr_len, size_t arr_stride, int dir); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #define BLI_array_wrap(arr, arr_len, dir) _bli_array_wrap(arr, arr_len, sizeof(*(arr)), dir)
 | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | void _bli_array_permute(void *arr, | 
					
						
							|  |  |  |                         const unsigned int arr_len, | 
					
						
							|  |  |  |                         const size_t arr_stride, | 
					
						
							| 
									
										
										
										
											2020-09-04 20:59:13 +02:00
										 |  |  |                         const unsigned int *order, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |                         void *arr_temp); | 
					
						
							| 
									
										
										
										
											2015-04-28 04:10:31 +10:00
										 |  |  | #define BLI_array_permute(arr, arr_len, order) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   _bli_array_permute(arr, arr_len, sizeof(*(arr)), order, NULL) | 
					
						
							| 
									
										
										
										
											2018-08-01 16:12:36 +02:00
										 |  |  | #define BLI_array_permute_ex(arr, arr_len, order, arr_temp) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   _bli_array_permute(arr, arr_len, sizeof(*(arr)), order, arr_temp) | 
					
						
							| 
									
										
										
										
											2015-04-28 04:10:31 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | int _bli_array_findindex(const void *arr, unsigned int arr_len, size_t arr_stride, const void *p); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #define BLI_array_findindex(arr, arr_len, p) _bli_array_findindex(arr, arr_len, sizeof(*(arr)), p)
 | 
					
						
							| 
									
										
										
										
											2015-02-14 07:28:15 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-23 11:23:31 +10:00
										 |  |  | int _bli_array_rfindindex(const void *arr, unsigned int arr_len, size_t arr_stride, const void *p); | 
					
						
							|  |  |  | #define BLI_array_rfindindex(arr, arr_len, p) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   _bli_array_rfindindex(arr, arr_len, sizeof(*(arr)), p) | 
					
						
							| 
									
										
										
										
											2016-06-23 11:23:31 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | void _bli_array_binary_and( | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     void *arr, const void *arr_a, const void *arr_b, unsigned int arr_len, size_t arr_stride); | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | #define BLI_array_binary_and(arr, arr_a, arr_b, arr_len) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   (CHECK_TYPE_PAIR_INLINE(*(arr), *(arr_a)), \ | 
					
						
							|  |  |  |    CHECK_TYPE_PAIR_INLINE(*(arr), *(arr_b)), \ | 
					
						
							|  |  |  |    _bli_array_binary_and(arr, arr_a, arr_b, arr_len, sizeof(*(arr)))) | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | void _bli_array_binary_or( | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     void *arr, const void *arr_a, const void *arr_b, unsigned int arr_len, size_t arr_stride); | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | #define BLI_array_binary_or(arr, arr_a, arr_b, arr_len) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   (CHECK_TYPE_PAIR_INLINE(*(arr), *(arr_a)), \ | 
					
						
							|  |  |  |    CHECK_TYPE_PAIR_INLINE(*(arr), *(arr_b)), \ | 
					
						
							|  |  |  |    _bli_array_binary_or(arr, arr_a, arr_b, arr_len, sizeof(*(arr)))) | 
					
						
							| 
									
										
										
										
											2016-01-19 07:00:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | bool _bli_array_iter_span(const void *arr, | 
					
						
							|  |  |  |                           unsigned int arr_len, | 
					
						
							|  |  |  |                           size_t arr_stride, | 
					
						
							|  |  |  |                           bool use_wrap, | 
					
						
							|  |  |  |                           bool use_delimit_bounds, | 
					
						
							|  |  |  |                           bool (*test_fn)(const void *arr_item, void *user_data), | 
					
						
							|  |  |  |                           void *user_data, | 
					
						
							|  |  |  |                           unsigned int span_step[2], | 
					
						
							|  |  |  |                           unsigned int *r_span_len); | 
					
						
							| 
									
										
										
										
											2018-03-28 08:59:26 +02:00
										 |  |  | #define BLI_array_iter_span( \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     arr, arr_len, use_wrap, use_delimit_bounds, test_fn, user_data, span_step, r_span_len) \ | 
					
						
							|  |  |  |   _bli_array_iter_span(arr, \ | 
					
						
							|  |  |  |                        arr_len, \ | 
					
						
							|  |  |  |                        sizeof(*(arr)), \ | 
					
						
							|  |  |  |                        use_wrap, \ | 
					
						
							|  |  |  |                        use_delimit_bounds, \ | 
					
						
							|  |  |  |                        test_fn, \ | 
					
						
							|  |  |  |                        user_data, \ | 
					
						
							|  |  |  |                        span_step, \ | 
					
						
							|  |  |  |                        r_span_len) | 
					
						
							| 
									
										
										
										
											2016-05-02 18:01:00 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | bool _bli_array_is_zeroed(const void *arr, unsigned int arr_len, size_t arr_stride); | 
					
						
							|  |  |  | #define BLI_array_is_zeroed(arr, arr_len) _bli_array_is_zeroed(arr, arr_len, sizeof(*(arr)))
 | 
					
						
							| 
									
										
										
										
											2018-03-28 08:59:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-09 16:02:40 -03:00
										 |  |  | bool _bli_array_iter_spiral_square(const void *arr_v, | 
					
						
							|  |  |  |                                    const int arr_shape[2], | 
					
						
							|  |  |  |                                    const size_t elem_size, | 
					
						
							|  |  |  |                                    const int center[2], | 
					
						
							|  |  |  |                                    const bool (*test_fn)(const void *arr_item, void *user_data), | 
					
						
							|  |  |  |                                    void *user_data); | 
					
						
							|  |  |  | #define BLI_array_iter_spiral_square(arr, arr_shape, center, test_fn, user_data) \
 | 
					
						
							|  |  |  |   _bli_array_iter_spiral_square(arr, arr_shape, sizeof(*(arr)), center, test_fn, user_data) | 
					
						
							| 
									
										
										
										
											2020-03-02 15:04:53 +01:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 |