| 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 |
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 |
assert( items != NULL ); |
| 11 |
assert( order != NULL ); |
| 12 |
(*this_).next_idx = 0; |
| 13 |
(*this_).length = universal_array_index_sorter_get_count( order ); |
| 14 |
(*this_).items = items; |
| 15 |
(*this_).order = order; |
| 16 |
} |
| 17 |
|
| 18 |
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 |
(*this_).next_idx = 0; |
| 22 |
(*this_).length = (*that).next_idx; |
| 23 |
(*this_).items = (*that).items; |
| 24 |
(*this_).order = (*that).order; |
| 25 |
} |
| 26 |
|
| 27 |
static inline void layout_visible_classifier_iter_destroy( layout_visible_classifier_iter_t *this_ ) |
| 28 |
{ |
| 29 |
(*this_).next_idx = 0; |
| 30 |
(*this_).length = 0; |
| 31 |
(*this_).items = NULL; |
| 32 |
(*this_).order = NULL; |
| 33 |
} |
| 34 |
|
| 35 |
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 |
assert( (*this_).length <= universal_array_index_sorter_get_count( (*this_).order ) ); |
| 40 |
|
| 41 |
return ( (*this_).next_idx < (*this_).length ); |
| 42 |
} |
| 43 |
|
| 44 |
static inline layout_visible_classifier_t *layout_visible_classifier_iter_next_ptr( layout_visible_classifier_iter_t *this_ ) |
| 45 |
{ |
| 46 |
layout_visible_classifier_t *result = NULL; |
| 47 |
if ( layout_visible_classifier_iter_has_next( this_ ) ) |
| 48 |
{ |
| 49 |
uint32_t array_index = universal_array_index_sorter_get_array_index( (*this_).order, (*this_).next_idx ); |
| 50 |
assert( array_index < layout_visible_set_get_visible_classifier_count( (*this_).items ) ); |
| 51 |
result = layout_visible_set_get_visible_classifier_ptr( (*this_).items, array_index ); |
| 52 |
(*this_).next_idx ++; |
| 53 |
} |
| 54 |
return result; |
| 55 |
} |
| 56 |
|
| 57 |
static inline uint32_t layout_visible_classifier_iter_count_processed( const layout_visible_classifier_iter_t *this_ ) |
| 58 |
{ |
| 59 |
return (*this_).next_idx; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
/* |
| 64 |
Copyright 2025-2026 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 |
*/ |