Line data Source code
1 : /* File: layout_visible_classifier_iter.inl; Copyright and License: see below */
2 :
3 : #include "u8/u8_trace.h"
4 : #include <assert.h>
5 :
6 0 : static inline void layout_visible_classifier_iter_init( layout_visible_classifier_iter_t *this_,
7 : layout_visible_set_t *items,
8 : const universal_array_index_sorter_t *order )
9 : {
10 0 : assert( items != NULL );
11 0 : assert( order != NULL );
12 0 : (*this_).next_idx = 0;
13 0 : (*this_).length = universal_array_index_sorter_get_count( order );
14 0 : (*this_).items = items;
15 0 : (*this_).order = order;
16 0 : }
17 :
18 0 : static inline void layout_visible_classifier_iter_init_from_processed( layout_visible_classifier_iter_t *this_,
19 : const layout_visible_classifier_iter_t *that )
20 : {
21 0 : (*this_).next_idx = 0;
22 0 : (*this_).length = (*that).next_idx;
23 0 : (*this_).items = (*that).items;
24 0 : (*this_).order = (*that).order;
25 0 : }
26 :
27 0 : static inline void layout_visible_classifier_iter_destroy( layout_visible_classifier_iter_t *this_ )
28 : {
29 0 : (*this_).next_idx = 0;
30 0 : (*this_).length = 0;
31 0 : (*this_).items = NULL;
32 0 : (*this_).order = NULL;
33 0 : }
34 :
35 0 : static inline bool layout_visible_classifier_iter_has_next( const layout_visible_classifier_iter_t *this_ )
36 : {
37 : /* check that the size of the array has not shrinked */
38 : /* It should not have changed at all, but this cannot be checked here. */
39 0 : assert( (*this_).length <= universal_array_index_sorter_get_count( (*this_).order ) );
40 :
41 0 : return ( (*this_).next_idx < (*this_).length );
42 : }
43 :
44 0 : static inline layout_visible_classifier_t *layout_visible_classifier_iter_next_ptr( layout_visible_classifier_iter_t *this_ )
45 : {
46 0 : layout_visible_classifier_t *result = NULL;
47 0 : if ( layout_visible_classifier_iter_has_next( this_ ) )
48 : {
49 0 : uint32_t array_index = universal_array_index_sorter_get_array_index( (*this_).order, (*this_).next_idx );
50 0 : assert( array_index < layout_visible_set_get_visible_classifier_count( (*this_).items ) );
51 0 : result = layout_visible_set_get_visible_classifier_ptr( (*this_).items, array_index );
52 0 : (*this_).next_idx ++;
53 : }
54 0 : return result;
55 : }
56 :
57 0 : static inline uint32_t layout_visible_classifier_iter_count_processed( const layout_visible_classifier_iter_t *this_ )
58 : {
59 0 : return (*this_).next_idx;
60 : }
61 :
62 :
63 : /*
64 : Copyright 2025-2025 Andreas Warnke
65 :
66 : Licensed under the Apache License, Version 2.0 (the "License");
67 : you may not use this file except in compliance with the License.
68 : You may obtain a copy of the License at
69 :
70 : http://www.apache.org/licenses/LICENSE-2.0
71 :
72 : Unless required by applicable law or agreed to in writing, software
73 : distributed under the License is distributed on an "AS IS" BASIS,
74 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75 : See the License for the specific language governing permissions and
76 : limitations under the License.
77 : */
|