Line data Source code
1 : /* File: universal_array_index_iterator.h; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 :
5 2 : static inline void universal_array_index_iterator_init( universal_array_index_iterator_t *this_,
6 : const universal_array_index_sorter_t *index_list )
7 : {
8 2 : (*this_).next_index = 0;
9 2 : (*this_).index_list = index_list;
10 2 : }
11 :
12 2 : static inline void universal_array_index_iterator_reset( universal_array_index_iterator_t *this_ )
13 : {
14 2 : (*this_).next_index = 0;
15 2 : }
16 :
17 2 : static inline void universal_array_index_iterator_destroy( universal_array_index_iterator_t *this_ )
18 : {
19 2 : (*this_).index_list = NULL;
20 2 : }
21 :
22 7 : static inline bool universal_array_index_iterator_has_next( const universal_array_index_iterator_t *this_ )
23 : {
24 7 : return (*this_).next_index < universal_array_index_sorter_get_count( (*this_).index_list );
25 : }
26 :
27 4 : static inline uint32_t universal_array_index_iterator_next( universal_array_index_iterator_t *this_ )
28 : {
29 4 : uint32_t result_index = universal_array_index_sorter_get_array_index( (*this_).index_list, (*this_).next_index );
30 4 : (*this_).next_index ++;
31 4 : return result_index;
32 : }
33 :
34 :
35 : /*
36 : * Copyright 2026-2026 Andreas Warnke
37 : *
38 : * Licensed under the Apache License, Version 2.0 (the "License");
39 : * you may not use this file except in compliance with the License.
40 : * You may obtain a copy of the License at
41 : *
42 : * http://www.apache.org/licenses/LICENSE-2.0
43 : *
44 : * Unless required by applicable law or agreed to in writing, software
45 : * distributed under the License is distributed on an "AS IS" BASIS,
46 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47 : * See the License for the specific language governing permissions and
48 : * limitations under the License.
49 : */
|