Debian Codegraph @

pencil/include/layout/layout_relationship_iter.h

raw
1 /* File: layout_relationship_iter.h; Copyright and License: see below */
2
3 #ifndef LAYOUT_RELATIONSHIP_ITER_H
4 #define LAYOUT_RELATIONSHIP_ITER_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Iterator over sorted arrays of relationships.
10 */
11
12 #include "layout/layout_relationship.h"
13 #include "layout/layout_visible_set.h"
14 #include "u8list/universal_array_index_sorter.h"
15 #include <stdint.h>
16 #include <stdbool.h>
17
18 /*!
19 * \brief attributes of the iterator
20 */
21 struct layout_relationship_iter_struct {
22 uint32_t next_idx; /*!< next index on the order index_sorter, not the index in items */
23 uint32_t length; /*!< maximum entries to iterate over in index_sorter */
24 layout_visible_set_t *items;
25 const universal_array_index_sorter_t *order;
26 };
27
28 typedef struct layout_relationship_iter_struct layout_relationship_iter_t;
29
30 /*!
31 * \brief initializes the layout_relationship_iter_t
32 *
33 * \param this_ pointer to own object attributes
34 * \param items array of items to iterate over
35 * \param order sorted list of indexes which determine the order
36 */
37 static inline void layout_relationship_iter_init( layout_relationship_iter_t *this_,
38 layout_visible_set_t *items,
39 const universal_array_index_sorter_t *order
40 );
41
42 /*!
43 * \brief initializes the layout_relationship_iter_t to re-process the already processed items
44 *
45 * it ignores the not-yet-processed items and iterates only over the already processed items
46 *
47 * \param this_ pointer to own object attributes
48 * \param that pointer to layout_relationship_iter_t iterator, of which only the processed elements shall be re-processed
49 */
50 static inline void layout_relationship_iter_init_from_processed( layout_relationship_iter_t *this_,
51 const layout_relationship_iter_t *that
52 );
53
54 /*!
55 * \brief clones the layout_relationship_iter_t
56 *
57 * it ignores the already processed items and iterates only over the not-yet-processed items
58 *
59 * \param this_ pointer to own object attributes
60 * \param original pointer to original object attributes
61 */
62 static inline void layout_relationship_iter_copy( layout_relationship_iter_t *this_,
63 const layout_relationship_iter_t *original
64 );
65
66 /*!
67 * \brief resets the layout_relationship_iter_t struct to the start of the list
68 * \param this_ pointer to own object attributes
69 */
70 static inline void layout_relationship_iter_reset ( layout_relationship_iter_t *this_ );
71
72 /*!
73 * \brief destroys the layout_relationship_iter_t
74 *
75 * \param this_ pointer to own object attributes
76 */
77 static inline void layout_relationship_iter_destroy( layout_relationship_iter_t *this_ );
78
79 /*!
80 * \brief checks if there are more elements
81 *
82 * has_next() does not modify the iterator; multiple calls to has_next() do not skip elements.
83 *
84 * \param this_ pointer to own object attributes
85 * \return true if there is at least one more element.
86 */
87 static inline bool layout_relationship_iter_has_next( const layout_relationship_iter_t *this_ );
88
89 /*!
90 * \brief gets the next layout_relationship_t if there are more, NULL otherwise.
91 *
92 * \param this_ pointer to own object attributes
93 * \return the next layout_relationship_t
94 */
95 static inline layout_relationship_t *layout_relationship_iter_next_ptr( layout_relationship_iter_t *this_ );
96
97 /*!
98 * \brief gets the next layout_relationship_t if there are more, NULL otherwise.
99 *
100 * \param this_ pointer to own object attributes
101 * \return the next layout_relationship_t
102 */
103 static inline const layout_relationship_t *layout_relationship_iter_next( layout_relationship_iter_t *this_ );
104
105 #include "layout_relationship_iter.inl"
106
107 #endif /* LAYOUT_RELATIONSHIP_ITER_H */
108
109
110 /*
111 Copyright 2025-2026 Andreas Warnke
112
113 Licensed under the Apache License, Version 2.0 (the "License");
114 you may not use this file except in compliance with the License.
115 You may obtain a copy of the License at
116
117 http://www.apache.org/licenses/LICENSE-2.0
118
119 Unless required by applicable law or agreed to in writing, software
120 distributed under the License is distributed on an "AS IS" BASIS,
121 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122 See the License for the specific language governing permissions and
123 limitations under the License.
124 */