/src/croaring/include/roaring/containers/run.h
Line | Count | Source |
1 | | /* |
2 | | * run.h |
3 | | * |
4 | | * Run containers store a set of 16-bit integers as a sorted array of |
5 | | * non-overlapping runs. Each run is represented by a starting value and a |
6 | | * length, encoding one contiguous interval of present integers. |
7 | | * |
8 | | * This representation is effective when the data contains long consecutive |
9 | | * ranges because it compresses many adjacent values into a small number of |
10 | | * run records while still supporting search and set operations over the |
11 | | * interval list. |
12 | | */ |
13 | | |
14 | | #ifndef INCLUDE_CONTAINERS_RUN_H_ |
15 | | #define INCLUDE_CONTAINERS_RUN_H_ |
16 | | |
17 | | #include <roaring/roaring_types.h> // roaring_iterator |
18 | | |
19 | | // Include other headers after roaring_types.h |
20 | | #include <assert.h> |
21 | | #include <stdbool.h> |
22 | | #include <stdint.h> |
23 | | #include <string.h> |
24 | | |
25 | | #include <roaring/array_util.h> // binarySearch()/memequals() for inlining |
26 | | #include <roaring/containers/container_defs.h> // container_t, perfparameters |
27 | | #include <roaring/portability.h> |
28 | | |
29 | | #ifdef __cplusplus |
30 | | extern "C" { |
31 | | namespace roaring { |
32 | | |
33 | | // Note: in pure C++ code, you should avoid putting `using` in header files |
34 | | using api::roaring_iterator; |
35 | | using api::roaring_iterator64; |
36 | | |
37 | | namespace internal { |
38 | | #endif |
39 | | |
40 | | /* struct rle16_s - run length pair |
41 | | * |
42 | | * @value: start position of the run |
43 | | * @length: length of the run is `length + 1` |
44 | | * |
45 | | * An RLE pair {v, l} would represent the integers between the interval |
46 | | * [v, v+l+1], e.g. {3, 2} = [3, 4, 5]. |
47 | | */ |
48 | | struct rle16_s { |
49 | | uint16_t value; |
50 | | uint16_t length; |
51 | | }; |
52 | | |
53 | | typedef struct rle16_s rle16_t; |
54 | | |
55 | | #ifdef __cplusplus |
56 | | #define CROARING_MAKE_RLE16(val, len) \ |
57 | | { (uint16_t)(val), (uint16_t)(len) } // no tagged structs until c++20 |
58 | | #else |
59 | | #define CROARING_MAKE_RLE16(val, len) \ |
60 | 390k | (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) } |
61 | | #endif |
62 | | |
63 | | /* struct run_container_s - run container bitmap |
64 | | * |
65 | | * @n_runs: number of rle_t pairs in `runs`. |
66 | | * @capacity: capacity in rle_t pairs `runs` can hold. |
67 | | * @runs: pairs of rle_t. |
68 | | */ |
69 | | STRUCT_CONTAINER(run_container_s) { |
70 | | int32_t n_runs; |
71 | | int32_t capacity; |
72 | | rle16_t *runs; |
73 | | }; |
74 | | |
75 | | typedef struct run_container_s run_container_t; |
76 | | |
77 | 1.26M | #define CAST_run(c) CAST(run_container_t *, c) // safer downcast |
78 | 987k | #define const_CAST_run(c) CAST(const run_container_t *, c) |
79 | | #define movable_CAST_run(c) movable_CAST(run_container_t **, c) |
80 | | |
81 | | /* Create a new run container. Return NULL in case of failure. */ |
82 | | run_container_t *run_container_create(void); |
83 | | |
84 | | /* Create a new run container with given capacity. Return NULL in case of |
85 | | * failure. */ |
86 | | run_container_t *run_container_create_given_capacity(int32_t size); |
87 | | |
88 | | /* |
89 | | * Shrink the capacity to the actual size, return the number of bytes saved. |
90 | | */ |
91 | | int run_container_shrink_to_fit(run_container_t *src); |
92 | | |
93 | | /* Free memory owned by `run'. */ |
94 | | void run_container_free(run_container_t *run); |
95 | | |
96 | | /* Duplicate container */ |
97 | | run_container_t *run_container_clone(const run_container_t *src); |
98 | | |
99 | | /* |
100 | | * Effectively deletes the value at index index, repacking data. |
101 | | */ |
102 | 6.99k | static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) { |
103 | 6.99k | memmove(run->runs + index, run->runs + (1 + index), |
104 | 6.99k | (run->n_runs - index - 1) * sizeof(rle16_t)); |
105 | 6.99k | run->n_runs--; |
106 | 6.99k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::recoverRoomAtIndex(roaring::internal::run_container_s*, unsigned short) roaring.c:recoverRoomAtIndex Line | Count | Source | 102 | 248 | static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) { | 103 | 248 | memmove(run->runs + index, run->runs + (1 + index), | 104 | 248 | (run->n_runs - index - 1) * sizeof(rle16_t)); | 105 | 248 | run->n_runs--; | 106 | 248 | } |
Unexecuted instantiation: roaring_array.c:recoverRoomAtIndex Unexecuted instantiation: containers.c:recoverRoomAtIndex Unexecuted instantiation: convert.c:recoverRoomAtIndex Unexecuted instantiation: mixed_intersection.c:recoverRoomAtIndex Unexecuted instantiation: mixed_union.c:recoverRoomAtIndex Unexecuted instantiation: mixed_equal.c:recoverRoomAtIndex Unexecuted instantiation: mixed_subset.c:recoverRoomAtIndex Unexecuted instantiation: mixed_negation.c:recoverRoomAtIndex Unexecuted instantiation: mixed_xor.c:recoverRoomAtIndex Unexecuted instantiation: mixed_andnot.c:recoverRoomAtIndex Line | Count | Source | 102 | 6.74k | static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) { | 103 | 6.74k | memmove(run->runs + index, run->runs + (1 + index), | 104 | 6.74k | (run->n_runs - index - 1) * sizeof(rle16_t)); | 105 | 6.74k | run->n_runs--; | 106 | 6.74k | } |
Unexecuted instantiation: croaring_fuzzer.c:recoverRoomAtIndex Unexecuted instantiation: roaring64.c:recoverRoomAtIndex |
107 | | |
108 | | /** |
109 | | * Good old binary search through rle data |
110 | | */ |
111 | | inline int32_t interleavedBinarySearch(const rle16_t *array, int32_t lenarray, |
112 | 771k | uint16_t ikey) { |
113 | 771k | int32_t low = 0; |
114 | 771k | int32_t high = lenarray - 1; |
115 | 2.96M | while (low <= high) { |
116 | 2.38M | int32_t middleIndex = (low + high) >> 1; |
117 | 2.38M | uint16_t middleValue = array[middleIndex].value; |
118 | 2.38M | if (middleValue < ikey) { |
119 | 1.13M | low = middleIndex + 1; |
120 | 1.25M | } else if (middleValue > ikey) { |
121 | 1.05M | high = middleIndex - 1; |
122 | 1.05M | } else { |
123 | 194k | return middleIndex; |
124 | 194k | } |
125 | 2.38M | } |
126 | 576k | return -(low + 1); |
127 | 771k | } |
128 | | |
129 | | /* |
130 | | * Returns index of the run which contains $ikey |
131 | | */ |
132 | | static inline int32_t rle16_find_run(const rle16_t *array, int32_t lenarray, |
133 | 3.54k | uint16_t ikey) { |
134 | 3.54k | int32_t low = 0; |
135 | 3.54k | int32_t high = lenarray - 1; |
136 | 15.1k | while (low <= high) { |
137 | 12.8k | int32_t middleIndex = (low + high) >> 1; |
138 | 12.8k | uint16_t min = array[middleIndex].value; |
139 | 12.8k | uint16_t max = array[middleIndex].value + array[middleIndex].length; |
140 | 12.8k | if (ikey > max) { |
141 | 1.72k | low = middleIndex + 1; |
142 | 11.1k | } else if (ikey < min) { |
143 | 9.88k | high = middleIndex - 1; |
144 | 9.88k | } else { |
145 | 1.23k | return middleIndex; |
146 | 1.23k | } |
147 | 12.8k | } |
148 | 2.31k | return -(low + 1); |
149 | 3.54k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::rle16_find_run(roaring::internal::rle16_s const*, int, unsigned short) Line | Count | Source | 133 | 3.54k | uint16_t ikey) { | 134 | 3.54k | int32_t low = 0; | 135 | 3.54k | int32_t high = lenarray - 1; | 136 | 15.1k | while (low <= high) { | 137 | 12.8k | int32_t middleIndex = (low + high) >> 1; | 138 | 12.8k | uint16_t min = array[middleIndex].value; | 139 | 12.8k | uint16_t max = array[middleIndex].value + array[middleIndex].length; | 140 | 12.8k | if (ikey > max) { | 141 | 1.72k | low = middleIndex + 1; | 142 | 11.1k | } else if (ikey < min) { | 143 | 9.88k | high = middleIndex - 1; | 144 | 9.88k | } else { | 145 | 1.23k | return middleIndex; | 146 | 1.23k | } | 147 | 12.8k | } | 148 | 2.31k | return -(low + 1); | 149 | 3.54k | } |
Unexecuted instantiation: roaring_array.c:rle16_find_run Unexecuted instantiation: containers.c:rle16_find_run Unexecuted instantiation: convert.c:rle16_find_run Unexecuted instantiation: mixed_intersection.c:rle16_find_run Unexecuted instantiation: mixed_union.c:rle16_find_run Unexecuted instantiation: mixed_equal.c:rle16_find_run Unexecuted instantiation: mixed_subset.c:rle16_find_run Unexecuted instantiation: mixed_negation.c:rle16_find_run Unexecuted instantiation: mixed_xor.c:rle16_find_run Unexecuted instantiation: mixed_andnot.c:rle16_find_run Unexecuted instantiation: run.c:rle16_find_run Unexecuted instantiation: croaring_fuzzer.c:rle16_find_run Unexecuted instantiation: roaring64.c:rle16_find_run |
150 | | |
151 | | /** |
152 | | * Returns number of runs which can'be be merged with the key because they |
153 | | * are less than the key. |
154 | | * Note that [5,6,7,8] can be merged with the key 9 and won't be counted. |
155 | | */ |
156 | | static inline int32_t rle16_count_less(const rle16_t *array, int32_t lenarray, |
157 | 453 | uint16_t key) { |
158 | 453 | if (lenarray == 0) return 0; |
159 | 452 | int32_t low = 0; |
160 | 452 | int32_t high = lenarray - 1; |
161 | 2.95k | while (low <= high) { |
162 | 2.73k | int32_t middleIndex = (low + high) >> 1; |
163 | 2.73k | uint16_t min_value = array[middleIndex].value; |
164 | 2.73k | uint16_t max_value = |
165 | 2.73k | array[middleIndex].value + array[middleIndex].length; |
166 | 2.73k | if (max_value + UINT32_C(1) < key) { // uint32 arithmetic |
167 | 1.37k | low = middleIndex + 1; |
168 | 1.37k | } else if (key < min_value) { |
169 | 1.13k | high = middleIndex - 1; |
170 | 1.13k | } else { |
171 | 227 | return middleIndex; |
172 | 227 | } |
173 | 2.73k | } |
174 | 225 | return low; |
175 | 452 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::rle16_count_less(roaring::internal::rle16_s const*, int, unsigned short) roaring.c:rle16_count_less Line | Count | Source | 157 | 453 | uint16_t key) { | 158 | 453 | if (lenarray == 0) return 0; | 159 | 452 | int32_t low = 0; | 160 | 452 | int32_t high = lenarray - 1; | 161 | 2.95k | while (low <= high) { | 162 | 2.73k | int32_t middleIndex = (low + high) >> 1; | 163 | 2.73k | uint16_t min_value = array[middleIndex].value; | 164 | 2.73k | uint16_t max_value = | 165 | 2.73k | array[middleIndex].value + array[middleIndex].length; | 166 | 2.73k | if (max_value + UINT32_C(1) < key) { // uint32 arithmetic | 167 | 1.37k | low = middleIndex + 1; | 168 | 1.37k | } else if (key < min_value) { | 169 | 1.13k | high = middleIndex - 1; | 170 | 1.13k | } else { | 171 | 227 | return middleIndex; | 172 | 227 | } | 173 | 2.73k | } | 174 | 225 | return low; | 175 | 452 | } |
Unexecuted instantiation: roaring_array.c:rle16_count_less Unexecuted instantiation: containers.c:rle16_count_less Unexecuted instantiation: convert.c:rle16_count_less Unexecuted instantiation: mixed_intersection.c:rle16_count_less Unexecuted instantiation: mixed_union.c:rle16_count_less Unexecuted instantiation: mixed_equal.c:rle16_count_less Unexecuted instantiation: mixed_subset.c:rle16_count_less Unexecuted instantiation: mixed_negation.c:rle16_count_less Unexecuted instantiation: mixed_xor.c:rle16_count_less Unexecuted instantiation: mixed_andnot.c:rle16_count_less Unexecuted instantiation: run.c:rle16_count_less Unexecuted instantiation: croaring_fuzzer.c:rle16_count_less Unexecuted instantiation: roaring64.c:rle16_count_less |
176 | | |
177 | | static inline int32_t rle16_count_greater(const rle16_t *array, |
178 | 453 | int32_t lenarray, uint16_t key) { |
179 | 453 | if (lenarray == 0) return 0; |
180 | 453 | int32_t low = 0; |
181 | 453 | int32_t high = lenarray - 1; |
182 | 3.50k | while (low <= high) { |
183 | 3.07k | int32_t middleIndex = (low + high) >> 1; |
184 | 3.07k | uint16_t min_value = array[middleIndex].value; |
185 | 3.07k | uint16_t max_value = |
186 | 3.07k | array[middleIndex].value + array[middleIndex].length; |
187 | 3.07k | if (max_value < key) { |
188 | 2.85k | low = middleIndex + 1; |
189 | 2.85k | } else if (key + UINT32_C(1) < min_value) { // uint32 arithmetic |
190 | 192 | high = middleIndex - 1; |
191 | 192 | } else { |
192 | 25 | return lenarray - (middleIndex + 1); |
193 | 25 | } |
194 | 3.07k | } |
195 | 428 | return lenarray - low; |
196 | 453 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::rle16_count_greater(roaring::internal::rle16_s const*, int, unsigned short) roaring.c:rle16_count_greater Line | Count | Source | 178 | 453 | int32_t lenarray, uint16_t key) { | 179 | 453 | if (lenarray == 0) return 0; | 180 | 453 | int32_t low = 0; | 181 | 453 | int32_t high = lenarray - 1; | 182 | 3.50k | while (low <= high) { | 183 | 3.07k | int32_t middleIndex = (low + high) >> 1; | 184 | 3.07k | uint16_t min_value = array[middleIndex].value; | 185 | 3.07k | uint16_t max_value = | 186 | 3.07k | array[middleIndex].value + array[middleIndex].length; | 187 | 3.07k | if (max_value < key) { | 188 | 2.85k | low = middleIndex + 1; | 189 | 2.85k | } else if (key + UINT32_C(1) < min_value) { // uint32 arithmetic | 190 | 192 | high = middleIndex - 1; | 191 | 192 | } else { | 192 | 25 | return lenarray - (middleIndex + 1); | 193 | 25 | } | 194 | 3.07k | } | 195 | 428 | return lenarray - low; | 196 | 453 | } |
Unexecuted instantiation: roaring_array.c:rle16_count_greater Unexecuted instantiation: containers.c:rle16_count_greater Unexecuted instantiation: convert.c:rle16_count_greater Unexecuted instantiation: mixed_intersection.c:rle16_count_greater Unexecuted instantiation: mixed_union.c:rle16_count_greater Unexecuted instantiation: mixed_equal.c:rle16_count_greater Unexecuted instantiation: mixed_subset.c:rle16_count_greater Unexecuted instantiation: mixed_negation.c:rle16_count_greater Unexecuted instantiation: mixed_xor.c:rle16_count_greater Unexecuted instantiation: mixed_andnot.c:rle16_count_greater Unexecuted instantiation: run.c:rle16_count_greater Unexecuted instantiation: croaring_fuzzer.c:rle16_count_greater Unexecuted instantiation: roaring64.c:rle16_count_greater |
197 | | |
198 | | /** |
199 | | * increase capacity to at least min. Whether the |
200 | | * existing data needs to be copied over depends on copy. If "copy" is false, |
201 | | * then the new content will be uninitialized, otherwise a copy is made. |
202 | | */ |
203 | | void run_container_grow(run_container_t *run, int32_t min, bool copy); |
204 | | |
205 | | /** |
206 | | * Moves the data so that we can write data at index |
207 | | */ |
208 | 46.3k | static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) { |
209 | | /* This function calls realloc + memmove sequentially to move by one index. |
210 | | * Potentially copying twice the array. |
211 | | */ |
212 | 46.3k | if (run->n_runs + 1 > run->capacity) |
213 | 3.48k | run_container_grow(run, run->n_runs + 1, true); |
214 | 46.3k | memmove(run->runs + 1 + index, run->runs + index, |
215 | 46.3k | (run->n_runs - index) * sizeof(rle16_t)); |
216 | 46.3k | run->n_runs++; |
217 | 46.3k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::makeRoomAtIndex(roaring::internal::run_container_s*, unsigned short) roaring.c:makeRoomAtIndex Line | Count | Source | 208 | 912 | static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) { | 209 | | /* This function calls realloc + memmove sequentially to move by one index. | 210 | | * Potentially copying twice the array. | 211 | | */ | 212 | 912 | if (run->n_runs + 1 > run->capacity) | 213 | 758 | run_container_grow(run, run->n_runs + 1, true); | 214 | 912 | memmove(run->runs + 1 + index, run->runs + index, | 215 | 912 | (run->n_runs - index) * sizeof(rle16_t)); | 216 | 912 | run->n_runs++; | 217 | 912 | } |
Unexecuted instantiation: roaring_array.c:makeRoomAtIndex Unexecuted instantiation: containers.c:makeRoomAtIndex Unexecuted instantiation: convert.c:makeRoomAtIndex Unexecuted instantiation: mixed_intersection.c:makeRoomAtIndex Unexecuted instantiation: mixed_union.c:makeRoomAtIndex Unexecuted instantiation: mixed_equal.c:makeRoomAtIndex Unexecuted instantiation: mixed_subset.c:makeRoomAtIndex Unexecuted instantiation: mixed_negation.c:makeRoomAtIndex Unexecuted instantiation: mixed_xor.c:makeRoomAtIndex Unexecuted instantiation: mixed_andnot.c:makeRoomAtIndex Line | Count | Source | 208 | 45.3k | static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) { | 209 | | /* This function calls realloc + memmove sequentially to move by one index. | 210 | | * Potentially copying twice the array. | 211 | | */ | 212 | 45.3k | if (run->n_runs + 1 > run->capacity) | 213 | 2.72k | run_container_grow(run, run->n_runs + 1, true); | 214 | 45.3k | memmove(run->runs + 1 + index, run->runs + index, | 215 | 45.3k | (run->n_runs - index) * sizeof(rle16_t)); | 216 | 45.3k | run->n_runs++; | 217 | 45.3k | } |
Unexecuted instantiation: croaring_fuzzer.c:makeRoomAtIndex Unexecuted instantiation: roaring64.c:makeRoomAtIndex |
218 | | |
219 | | /* Add `pos' to `run'. Returns true if `pos' was not present. */ |
220 | | bool run_container_add(run_container_t *run, uint16_t pos); |
221 | | |
222 | | /* Remove `pos' from `run'. Returns true if `pos' was present. */ |
223 | 3.12k | static inline bool run_container_remove(run_container_t *run, uint16_t pos) { |
224 | 3.12k | int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos); |
225 | 3.12k | if (index >= 0) { |
226 | 1.18k | int32_t le = run->runs[index].length; |
227 | 1.18k | if (le == 0) { |
228 | 248 | recoverRoomAtIndex(run, (uint16_t)index); |
229 | 939 | } else { |
230 | 939 | run->runs[index].value++; |
231 | 939 | run->runs[index].length--; |
232 | 939 | } |
233 | 1.18k | return true; |
234 | 1.18k | } |
235 | 1.93k | index = -index - 2; // points to preceding value, possibly -1 |
236 | 1.93k | if (index >= 0) { // possible match |
237 | 956 | int32_t offset = pos - run->runs[index].value; |
238 | 956 | int32_t le = run->runs[index].length; |
239 | 956 | if (offset < le) { |
240 | | // need to break in two |
241 | 724 | run->runs[index].length = (uint16_t)(offset - 1); |
242 | | // need to insert |
243 | 724 | uint16_t newvalue = pos + 1; |
244 | 724 | int32_t newlength = le - offset - 1; |
245 | 724 | makeRoomAtIndex(run, (uint16_t)(index + 1)); |
246 | 724 | run->runs[index + 1].value = newvalue; |
247 | 724 | run->runs[index + 1].length = (uint16_t)newlength; |
248 | 724 | return true; |
249 | | |
250 | 724 | } else if (offset == le) { |
251 | 37 | run->runs[index].length--; |
252 | 37 | return true; |
253 | 37 | } |
254 | 956 | } |
255 | | // no match |
256 | 1.17k | return false; |
257 | 1.93k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_remove(roaring::internal::run_container_s*, unsigned short) roaring.c:run_container_remove Line | Count | Source | 223 | 3.12k | static inline bool run_container_remove(run_container_t *run, uint16_t pos) { | 224 | 3.12k | int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos); | 225 | 3.12k | if (index >= 0) { | 226 | 1.18k | int32_t le = run->runs[index].length; | 227 | 1.18k | if (le == 0) { | 228 | 248 | recoverRoomAtIndex(run, (uint16_t)index); | 229 | 939 | } else { | 230 | 939 | run->runs[index].value++; | 231 | 939 | run->runs[index].length--; | 232 | 939 | } | 233 | 1.18k | return true; | 234 | 1.18k | } | 235 | 1.93k | index = -index - 2; // points to preceding value, possibly -1 | 236 | 1.93k | if (index >= 0) { // possible match | 237 | 956 | int32_t offset = pos - run->runs[index].value; | 238 | 956 | int32_t le = run->runs[index].length; | 239 | 956 | if (offset < le) { | 240 | | // need to break in two | 241 | 724 | run->runs[index].length = (uint16_t)(offset - 1); | 242 | | // need to insert | 243 | 724 | uint16_t newvalue = pos + 1; | 244 | 724 | int32_t newlength = le - offset - 1; | 245 | 724 | makeRoomAtIndex(run, (uint16_t)(index + 1)); | 246 | 724 | run->runs[index + 1].value = newvalue; | 247 | 724 | run->runs[index + 1].length = (uint16_t)newlength; | 248 | 724 | return true; | 249 | | | 250 | 724 | } else if (offset == le) { | 251 | 37 | run->runs[index].length--; | 252 | 37 | return true; | 253 | 37 | } | 254 | 956 | } | 255 | | // no match | 256 | 1.17k | return false; | 257 | 1.93k | } |
Unexecuted instantiation: roaring_array.c:run_container_remove Unexecuted instantiation: containers.c:run_container_remove Unexecuted instantiation: convert.c:run_container_remove Unexecuted instantiation: mixed_intersection.c:run_container_remove Unexecuted instantiation: mixed_union.c:run_container_remove Unexecuted instantiation: mixed_equal.c:run_container_remove Unexecuted instantiation: mixed_subset.c:run_container_remove Unexecuted instantiation: mixed_negation.c:run_container_remove Unexecuted instantiation: mixed_xor.c:run_container_remove Unexecuted instantiation: mixed_andnot.c:run_container_remove Unexecuted instantiation: run.c:run_container_remove Unexecuted instantiation: croaring_fuzzer.c:run_container_remove Unexecuted instantiation: roaring64.c:run_container_remove |
258 | | |
259 | | /* Check whether `pos' is present in `run'. */ |
260 | 213k | inline bool run_container_contains(const run_container_t *run, uint16_t pos) { |
261 | 213k | int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos); |
262 | 213k | if (index >= 0) return true; |
263 | 205k | index = -index - 2; // points to preceding value, possibly -1 |
264 | 205k | if (index != -1) { // possible match |
265 | 204k | int32_t offset = pos - run->runs[index].value; |
266 | 204k | int32_t le = run->runs[index].length; |
267 | 204k | if (offset <= le) return true; |
268 | 204k | } |
269 | 148k | return false; |
270 | 205k | } |
271 | | |
272 | | /* |
273 | | * Check whether all positions in a range of positions from pos_start (included) |
274 | | * to pos_end (excluded) is present in `run'. |
275 | | */ |
276 | | static inline bool run_container_contains_range(const run_container_t *run, |
277 | | uint32_t pos_start, |
278 | 188 | uint32_t pos_end) { |
279 | 188 | uint32_t count = 0; |
280 | 188 | int32_t index = |
281 | 188 | interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start); |
282 | 188 | if (index < 0) { |
283 | 120 | index = -index - 2; |
284 | 120 | if ((index == -1) || |
285 | 108 | ((pos_start - run->runs[index].value) > run->runs[index].length)) { |
286 | 42 | return false; |
287 | 42 | } |
288 | 120 | } |
289 | 2.26k | for (int32_t i = index; i < run->n_runs; ++i) { |
290 | 2.20k | const uint32_t stop = run->runs[i].value + run->runs[i].length; |
291 | 2.20k | if (run->runs[i].value >= pos_end) break; |
292 | 2.19k | if (stop >= pos_end) { |
293 | 76 | count += (((pos_end - run->runs[i].value) > 0) |
294 | 76 | ? (pos_end - run->runs[i].value) |
295 | 76 | : 0); |
296 | 76 | break; |
297 | 76 | } |
298 | 2.11k | const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0; |
299 | 2.11k | count += (min < run->runs[i].length) ? min : run->runs[i].length; |
300 | 2.11k | } |
301 | 146 | return count >= (pos_end - pos_start - 1); |
302 | 188 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_contains_range(roaring::internal::run_container_s const*, unsigned int, unsigned int) roaring.c:run_container_contains_range Line | Count | Source | 278 | 188 | uint32_t pos_end) { | 279 | 188 | uint32_t count = 0; | 280 | 188 | int32_t index = | 281 | 188 | interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start); | 282 | 188 | if (index < 0) { | 283 | 120 | index = -index - 2; | 284 | 120 | if ((index == -1) || | 285 | 108 | ((pos_start - run->runs[index].value) > run->runs[index].length)) { | 286 | 42 | return false; | 287 | 42 | } | 288 | 120 | } | 289 | 2.26k | for (int32_t i = index; i < run->n_runs; ++i) { | 290 | 2.20k | const uint32_t stop = run->runs[i].value + run->runs[i].length; | 291 | 2.20k | if (run->runs[i].value >= pos_end) break; | 292 | 2.19k | if (stop >= pos_end) { | 293 | 76 | count += (((pos_end - run->runs[i].value) > 0) | 294 | 76 | ? (pos_end - run->runs[i].value) | 295 | 76 | : 0); | 296 | 76 | break; | 297 | 76 | } | 298 | 2.11k | const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0; | 299 | 2.11k | count += (min < run->runs[i].length) ? min : run->runs[i].length; | 300 | 2.11k | } | 301 | 146 | return count >= (pos_end - pos_start - 1); | 302 | 188 | } |
Unexecuted instantiation: roaring_array.c:run_container_contains_range Unexecuted instantiation: containers.c:run_container_contains_range Unexecuted instantiation: convert.c:run_container_contains_range Unexecuted instantiation: mixed_intersection.c:run_container_contains_range Unexecuted instantiation: mixed_union.c:run_container_contains_range Unexecuted instantiation: mixed_equal.c:run_container_contains_range Unexecuted instantiation: mixed_subset.c:run_container_contains_range Unexecuted instantiation: mixed_negation.c:run_container_contains_range Unexecuted instantiation: mixed_xor.c:run_container_contains_range Unexecuted instantiation: mixed_andnot.c:run_container_contains_range Unexecuted instantiation: run.c:run_container_contains_range Unexecuted instantiation: croaring_fuzzer.c:run_container_contains_range Unexecuted instantiation: roaring64.c:run_container_contains_range |
303 | | |
304 | | /* Get the cardinality of `run'. Requires an actual computation. */ |
305 | | int run_container_cardinality(const run_container_t *run); |
306 | | |
307 | | /* Card > 0?, see run_container_empty for the reverse */ |
308 | | static inline bool run_container_nonzero_cardinality( |
309 | 66.0k | const run_container_t *run) { |
310 | 66.0k | return run->n_runs > 0; // runs never empty |
311 | 66.0k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_nonzero_cardinality(roaring::internal::run_container_s const*) roaring.c:run_container_nonzero_cardinality Line | Count | Source | 309 | 66.0k | const run_container_t *run) { | 310 | 66.0k | return run->n_runs > 0; // runs never empty | 311 | 66.0k | } |
Unexecuted instantiation: roaring_array.c:run_container_nonzero_cardinality Unexecuted instantiation: containers.c:run_container_nonzero_cardinality Unexecuted instantiation: convert.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_intersection.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_union.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_equal.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_subset.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_negation.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_xor.c:run_container_nonzero_cardinality Unexecuted instantiation: mixed_andnot.c:run_container_nonzero_cardinality Unexecuted instantiation: run.c:run_container_nonzero_cardinality Unexecuted instantiation: croaring_fuzzer.c:run_container_nonzero_cardinality Unexecuted instantiation: roaring64.c:run_container_nonzero_cardinality |
312 | | |
313 | | /* Card == 0?, see run_container_nonzero_cardinality for the reverse */ |
314 | 16 | static inline bool run_container_empty(const run_container_t *run) { |
315 | 16 | return run->n_runs == 0; // runs never empty |
316 | 16 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_empty(roaring::internal::run_container_s const*) Unexecuted instantiation: roaring.c:run_container_empty Unexecuted instantiation: roaring_array.c:run_container_empty Unexecuted instantiation: containers.c:run_container_empty Unexecuted instantiation: convert.c:run_container_empty Unexecuted instantiation: mixed_intersection.c:run_container_empty Unexecuted instantiation: mixed_union.c:run_container_empty Unexecuted instantiation: mixed_equal.c:run_container_empty Unexecuted instantiation: mixed_subset.c:run_container_empty Unexecuted instantiation: mixed_negation.c:run_container_empty Unexecuted instantiation: mixed_xor.c:run_container_empty Unexecuted instantiation: mixed_andnot.c:run_container_empty run.c:run_container_empty Line | Count | Source | 314 | 16 | static inline bool run_container_empty(const run_container_t *run) { | 315 | 16 | return run->n_runs == 0; // runs never empty | 316 | 16 | } |
Unexecuted instantiation: croaring_fuzzer.c:run_container_empty Unexecuted instantiation: roaring64.c:run_container_empty |
317 | | |
318 | | /* Copy one container into another. We assume that they are distinct. */ |
319 | | void run_container_copy(const run_container_t *src, run_container_t *dst); |
320 | | |
321 | | /** |
322 | | * Append run described by vl to the run container, possibly merging. |
323 | | * It is assumed that the run would be inserted at the end of the container, no |
324 | | * check is made. |
325 | | * It is assumed that the run container has the necessary capacity: caller is |
326 | | * responsible for checking memory capacity. |
327 | | * |
328 | | * |
329 | | * This is not a safe function, it is meant for performance: use with care. |
330 | | */ |
331 | | static inline void run_container_append(run_container_t *run, rle16_t vl, |
332 | 476k | rle16_t *previousrl) { |
333 | 476k | const uint32_t previousend = previousrl->value + previousrl->length; |
334 | 476k | if (vl.value > previousend + 1) { // we add a new one |
335 | 315k | run->runs[run->n_runs] = vl; |
336 | 315k | run->n_runs++; |
337 | 315k | *previousrl = vl; |
338 | 315k | } else { |
339 | 161k | uint32_t newend = vl.value + vl.length + UINT32_C(1); |
340 | 161k | if (newend > previousend) { // we merge |
341 | 128k | previousrl->length = (uint16_t)(newend - 1 - previousrl->value); |
342 | 128k | run->runs[run->n_runs - 1] = *previousrl; |
343 | 128k | } |
344 | 161k | } |
345 | 476k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_append(roaring::internal::run_container_s*, roaring::internal::rle16_s, roaring::internal::rle16_s*) Unexecuted instantiation: roaring.c:run_container_append Unexecuted instantiation: roaring_array.c:run_container_append Unexecuted instantiation: containers.c:run_container_append Unexecuted instantiation: convert.c:run_container_append Unexecuted instantiation: mixed_intersection.c:run_container_append mixed_union.c:run_container_append Line | Count | Source | 332 | 168k | rle16_t *previousrl) { | 333 | 168k | const uint32_t previousend = previousrl->value + previousrl->length; | 334 | 168k | if (vl.value > previousend + 1) { // we add a new one | 335 | 155k | run->runs[run->n_runs] = vl; | 336 | 155k | run->n_runs++; | 337 | 155k | *previousrl = vl; | 338 | 155k | } else { | 339 | 12.9k | uint32_t newend = vl.value + vl.length + UINT32_C(1); | 340 | 12.9k | if (newend > previousend) { // we merge | 341 | 12.9k | previousrl->length = (uint16_t)(newend - 1 - previousrl->value); | 342 | 12.9k | run->runs[run->n_runs - 1] = *previousrl; | 343 | 12.9k | } | 344 | 12.9k | } | 345 | 168k | } |
Unexecuted instantiation: mixed_equal.c:run_container_append Unexecuted instantiation: mixed_subset.c:run_container_append Unexecuted instantiation: mixed_negation.c:run_container_append Unexecuted instantiation: mixed_xor.c:run_container_append Unexecuted instantiation: mixed_andnot.c:run_container_append run.c:run_container_append Line | Count | Source | 332 | 307k | rle16_t *previousrl) { | 333 | 307k | const uint32_t previousend = previousrl->value + previousrl->length; | 334 | 307k | if (vl.value > previousend + 1) { // we add a new one | 335 | 159k | run->runs[run->n_runs] = vl; | 336 | 159k | run->n_runs++; | 337 | 159k | *previousrl = vl; | 338 | 159k | } else { | 339 | 148k | uint32_t newend = vl.value + vl.length + UINT32_C(1); | 340 | 148k | if (newend > previousend) { // we merge | 341 | 115k | previousrl->length = (uint16_t)(newend - 1 - previousrl->value); | 342 | 115k | run->runs[run->n_runs - 1] = *previousrl; | 343 | 115k | } | 344 | 148k | } | 345 | 307k | } |
Unexecuted instantiation: croaring_fuzzer.c:run_container_append Unexecuted instantiation: roaring64.c:run_container_append |
346 | | |
347 | | /** |
348 | | * Like run_container_append but it is assumed that the content of run is empty. |
349 | | */ |
350 | | static inline rle16_t run_container_append_first(run_container_t *run, |
351 | 95.5k | rle16_t vl) { |
352 | 95.5k | run->runs[run->n_runs] = vl; |
353 | 95.5k | run->n_runs++; |
354 | 95.5k | return vl; |
355 | 95.5k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_append_first(roaring::internal::run_container_s*, roaring::internal::rle16_s) roaring.c:run_container_append_first Line | Count | Source | 351 | 91.0k | rle16_t vl) { | 352 | 91.0k | run->runs[run->n_runs] = vl; | 353 | 91.0k | run->n_runs++; | 354 | 91.0k | return vl; | 355 | 91.0k | } |
Unexecuted instantiation: roaring_array.c:run_container_append_first Unexecuted instantiation: containers.c:run_container_append_first Unexecuted instantiation: convert.c:run_container_append_first Unexecuted instantiation: mixed_intersection.c:run_container_append_first mixed_union.c:run_container_append_first Line | Count | Source | 351 | 2.14k | rle16_t vl) { | 352 | 2.14k | run->runs[run->n_runs] = vl; | 353 | 2.14k | run->n_runs++; | 354 | 2.14k | return vl; | 355 | 2.14k | } |
Unexecuted instantiation: mixed_equal.c:run_container_append_first Unexecuted instantiation: mixed_subset.c:run_container_append_first Unexecuted instantiation: mixed_negation.c:run_container_append_first Unexecuted instantiation: mixed_xor.c:run_container_append_first Unexecuted instantiation: mixed_andnot.c:run_container_append_first run.c:run_container_append_first Line | Count | Source | 351 | 2.37k | rle16_t vl) { | 352 | 2.37k | run->runs[run->n_runs] = vl; | 353 | 2.37k | run->n_runs++; | 354 | 2.37k | return vl; | 355 | 2.37k | } |
Unexecuted instantiation: croaring_fuzzer.c:run_container_append_first Unexecuted instantiation: roaring64.c:run_container_append_first |
356 | | |
357 | | /** |
358 | | * append a single value given by val to the run container, possibly merging. |
359 | | * It is assumed that the value would be inserted at the end of the container, |
360 | | * no check is made. |
361 | | * It is assumed that the run container has the necessary capacity: caller is |
362 | | * responsible for checking memory capacity. |
363 | | * |
364 | | * This is not a safe function, it is meant for performance: use with care. |
365 | | */ |
366 | | static inline void run_container_append_value(run_container_t *run, |
367 | | uint16_t val, |
368 | 512k | rle16_t *previousrl) { |
369 | 512k | const uint32_t previousend = previousrl->value + previousrl->length; |
370 | 512k | if (val > previousend + 1) { // we add a new one |
371 | 54.2k | *previousrl = CROARING_MAKE_RLE16(val, 0); |
372 | 54.2k | run->runs[run->n_runs] = *previousrl; |
373 | 54.2k | run->n_runs++; |
374 | 457k | } else if (val == previousend + 1) { // we merge |
375 | 161k | previousrl->length++; |
376 | 161k | run->runs[run->n_runs - 1] = *previousrl; |
377 | 161k | } |
378 | 512k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_append_value(roaring::internal::run_container_s*, unsigned short, roaring::internal::rle16_s*) Unexecuted instantiation: roaring.c:run_container_append_value Unexecuted instantiation: roaring_array.c:run_container_append_value Unexecuted instantiation: containers.c:run_container_append_value Unexecuted instantiation: convert.c:run_container_append_value Unexecuted instantiation: mixed_intersection.c:run_container_append_value mixed_union.c:run_container_append_value Line | Count | Source | 368 | 512k | rle16_t *previousrl) { | 369 | 512k | const uint32_t previousend = previousrl->value + previousrl->length; | 370 | 512k | if (val > previousend + 1) { // we add a new one | 371 | 54.2k | *previousrl = CROARING_MAKE_RLE16(val, 0); | 372 | 54.2k | run->runs[run->n_runs] = *previousrl; | 373 | 54.2k | run->n_runs++; | 374 | 457k | } else if (val == previousend + 1) { // we merge | 375 | 161k | previousrl->length++; | 376 | 161k | run->runs[run->n_runs - 1] = *previousrl; | 377 | 161k | } | 378 | 512k | } |
Unexecuted instantiation: mixed_equal.c:run_container_append_value Unexecuted instantiation: mixed_subset.c:run_container_append_value Unexecuted instantiation: mixed_negation.c:run_container_append_value Unexecuted instantiation: mixed_xor.c:run_container_append_value Unexecuted instantiation: mixed_andnot.c:run_container_append_value Unexecuted instantiation: run.c:run_container_append_value Unexecuted instantiation: croaring_fuzzer.c:run_container_append_value Unexecuted instantiation: roaring64.c:run_container_append_value |
379 | | |
380 | | /** |
381 | | * Like run_container_append_value but it is assumed that the content of run is |
382 | | * empty. |
383 | | */ |
384 | | static inline rle16_t run_container_append_value_first(run_container_t *run, |
385 | 673 | uint16_t val) { |
386 | 673 | rle16_t newrle = CROARING_MAKE_RLE16(val, 0); |
387 | 673 | run->runs[run->n_runs] = newrle; |
388 | 673 | run->n_runs++; |
389 | 673 | return newrle; |
390 | 673 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_append_value_first(roaring::internal::run_container_s*, unsigned short) Unexecuted instantiation: roaring.c:run_container_append_value_first Unexecuted instantiation: roaring_array.c:run_container_append_value_first Unexecuted instantiation: containers.c:run_container_append_value_first Unexecuted instantiation: convert.c:run_container_append_value_first Unexecuted instantiation: mixed_intersection.c:run_container_append_value_first mixed_union.c:run_container_append_value_first Line | Count | Source | 385 | 673 | uint16_t val) { | 386 | 673 | rle16_t newrle = CROARING_MAKE_RLE16(val, 0); | 387 | 673 | run->runs[run->n_runs] = newrle; | 388 | 673 | run->n_runs++; | 389 | 673 | return newrle; | 390 | 673 | } |
Unexecuted instantiation: mixed_equal.c:run_container_append_value_first Unexecuted instantiation: mixed_subset.c:run_container_append_value_first Unexecuted instantiation: mixed_negation.c:run_container_append_value_first Unexecuted instantiation: mixed_xor.c:run_container_append_value_first Unexecuted instantiation: mixed_andnot.c:run_container_append_value_first Unexecuted instantiation: run.c:run_container_append_value_first Unexecuted instantiation: croaring_fuzzer.c:run_container_append_value_first Unexecuted instantiation: roaring64.c:run_container_append_value_first |
391 | | |
392 | | /* Check whether the container spans the whole chunk (cardinality = 1<<16). |
393 | | * This check can be done in constant time (inexpensive). */ |
394 | 160k | static inline bool run_container_is_full(const run_container_t *run) { |
395 | 160k | rle16_t vl = run->runs[0]; |
396 | 160k | return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF); |
397 | 160k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_is_full(roaring::internal::run_container_s const*) roaring.c:run_container_is_full Line | Count | Source | 394 | 6.25k | static inline bool run_container_is_full(const run_container_t *run) { | 395 | 6.25k | rle16_t vl = run->runs[0]; | 396 | 6.25k | return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF); | 397 | 6.25k | } |
Unexecuted instantiation: roaring_array.c:run_container_is_full Unexecuted instantiation: containers.c:run_container_is_full Unexecuted instantiation: convert.c:run_container_is_full mixed_intersection.c:run_container_is_full Line | Count | Source | 394 | 17.5k | static inline bool run_container_is_full(const run_container_t *run) { | 395 | 17.5k | rle16_t vl = run->runs[0]; | 396 | 17.5k | return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF); | 397 | 17.5k | } |
mixed_union.c:run_container_is_full Line | Count | Source | 394 | 2.93k | static inline bool run_container_is_full(const run_container_t *run) { | 395 | 2.93k | rle16_t vl = run->runs[0]; | 396 | 2.93k | return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF); | 397 | 2.93k | } |
Unexecuted instantiation: mixed_equal.c:run_container_is_full Unexecuted instantiation: mixed_subset.c:run_container_is_full Unexecuted instantiation: mixed_negation.c:run_container_is_full Unexecuted instantiation: mixed_xor.c:run_container_is_full Unexecuted instantiation: mixed_andnot.c:run_container_is_full run.c:run_container_is_full Line | Count | Source | 394 | 134k | static inline bool run_container_is_full(const run_container_t *run) { | 395 | 134k | rle16_t vl = run->runs[0]; | 396 | 134k | return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF); | 397 | 134k | } |
Unexecuted instantiation: croaring_fuzzer.c:run_container_is_full Unexecuted instantiation: roaring64.c:run_container_is_full |
398 | | |
399 | | /* Compute the union of `src_1' and `src_2' and write the result to `dst' |
400 | | * It is assumed that `dst' is distinct from both `src_1' and `src_2'. */ |
401 | | void run_container_union(const run_container_t *src_1, |
402 | | const run_container_t *src_2, run_container_t *dst); |
403 | | |
404 | | /* Compute the union of `src_1' and `src_2' and write the result to `src_1' */ |
405 | | void run_container_union_inplace(run_container_t *src_1, |
406 | | const run_container_t *src_2); |
407 | | |
408 | | /* Compute the intersection of src_1 and src_2 and write the result to |
409 | | * dst. It is assumed that dst is distinct from both src_1 and src_2. */ |
410 | | void run_container_intersection(const run_container_t *src_1, |
411 | | const run_container_t *src_2, |
412 | | run_container_t *dst); |
413 | | |
414 | | /* Compute the size of the intersection of src_1 and src_2 . */ |
415 | | int run_container_intersection_cardinality(const run_container_t *src_1, |
416 | | const run_container_t *src_2); |
417 | | |
418 | | /* Check whether src_1 and src_2 intersect. */ |
419 | | bool run_container_intersect(const run_container_t *src_1, |
420 | | const run_container_t *src_2); |
421 | | |
422 | | /* Compute the symmetric difference of `src_1' and `src_2' and write the result |
423 | | * to `dst' |
424 | | * It is assumed that `dst' is distinct from both `src_1' and `src_2'. */ |
425 | | void run_container_xor(const run_container_t *src_1, |
426 | | const run_container_t *src_2, run_container_t *dst); |
427 | | |
428 | | /* |
429 | | * Write out the 16-bit integers contained in this container as a list of 32-bit |
430 | | * integers using base |
431 | | * as the starting value (it might be expected that base has zeros in its 16 |
432 | | * least significant bits). |
433 | | * The function returns the number of values written. |
434 | | * The caller is responsible for allocating enough memory in out. |
435 | | */ |
436 | | int run_container_to_uint32_array(void *vout, const run_container_t *cont, |
437 | | uint32_t base); |
438 | | |
439 | | /* |
440 | | * Print this container using printf (useful for debugging). |
441 | | */ |
442 | | void run_container_printf(const run_container_t *v); |
443 | | |
444 | | /* |
445 | | * Print this container using printf as a comma-separated list of 32-bit |
446 | | * integers starting at base. |
447 | | */ |
448 | | void run_container_printf_as_uint32_array(const run_container_t *v, |
449 | | uint32_t base); |
450 | | |
451 | | bool run_container_validate(const run_container_t *run, const char **reason); |
452 | | |
453 | | /** |
454 | | * Return the serialized size in bytes of a container having "num_runs" runs. |
455 | | */ |
456 | 227k | static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) { |
457 | 227k | return sizeof(uint16_t) + |
458 | 227k | sizeof(rle16_t) * num_runs; // each run requires 2 2-byte entries. |
459 | 227k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_serialized_size_in_bytes(int) Unexecuted instantiation: roaring.c:run_container_serialized_size_in_bytes roaring_array.c:run_container_serialized_size_in_bytes Line | Count | Source | 456 | 2.63k | static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) { | 457 | 2.63k | return sizeof(uint16_t) + | 458 | 2.63k | sizeof(rle16_t) * num_runs; // each run requires 2 2-byte entries. | 459 | 2.63k | } |
Unexecuted instantiation: containers.c:run_container_serialized_size_in_bytes convert.c:run_container_serialized_size_in_bytes Line | Count | Source | 456 | 152k | static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) { | 457 | 152k | return sizeof(uint16_t) + | 458 | 152k | sizeof(rle16_t) * num_runs; // each run requires 2 2-byte entries. | 459 | 152k | } |
Unexecuted instantiation: mixed_intersection.c:run_container_serialized_size_in_bytes Unexecuted instantiation: mixed_union.c:run_container_serialized_size_in_bytes Unexecuted instantiation: mixed_equal.c:run_container_serialized_size_in_bytes Unexecuted instantiation: mixed_subset.c:run_container_serialized_size_in_bytes Unexecuted instantiation: mixed_negation.c:run_container_serialized_size_in_bytes Unexecuted instantiation: mixed_xor.c:run_container_serialized_size_in_bytes Unexecuted instantiation: mixed_andnot.c:run_container_serialized_size_in_bytes run.c:run_container_serialized_size_in_bytes Line | Count | Source | 456 | 72.0k | static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) { | 457 | 72.0k | return sizeof(uint16_t) + | 458 | 72.0k | sizeof(rle16_t) * num_runs; // each run requires 2 2-byte entries. | 459 | 72.0k | } |
Unexecuted instantiation: croaring_fuzzer.c:run_container_serialized_size_in_bytes Unexecuted instantiation: roaring64.c:run_container_serialized_size_in_bytes |
460 | | |
461 | | bool run_container_iterate(const run_container_t *cont, uint32_t base, |
462 | | roaring_iterator iterator, void *ptr); |
463 | | bool run_container_iterate64(const run_container_t *cont, uint32_t base, |
464 | | roaring_iterator64 iterator, uint64_t high_bits, |
465 | | void *ptr); |
466 | | |
467 | | /** |
468 | | * Writes the underlying array to buf, outputs how many bytes were written. |
469 | | * This is meant to be byte-by-byte compatible with the Java and Go versions of |
470 | | * Roaring. |
471 | | * The number of bytes written should be run_container_size_in_bytes(container). |
472 | | */ |
473 | | int32_t run_container_write(const run_container_t *container, char *buf); |
474 | | |
475 | | /** |
476 | | * Reads the instance from buf, outputs how many bytes were read. |
477 | | * This is meant to be byte-by-byte compatible with the Java and Go versions of |
478 | | * Roaring. |
479 | | * The number of bytes read should be bitset_container_size_in_bytes(container). |
480 | | * The cardinality parameter is provided for consistency with other containers, |
481 | | * but |
482 | | * it might be effectively ignored.. |
483 | | */ |
484 | | int32_t run_container_read(int32_t cardinality, run_container_t *container, |
485 | | const char *buf); |
486 | | |
487 | | /** |
488 | | * Return the serialized size in bytes of a container (see run_container_write). |
489 | | * This is meant to be compatible with the Java and Go versions of Roaring. |
490 | | */ |
491 | | CROARING_ALLOW_UNALIGNED |
492 | | static inline int32_t run_container_size_in_bytes( |
493 | 74.6k | const run_container_t *container) { |
494 | 74.6k | return run_container_serialized_size_in_bytes(container->n_runs); |
495 | 74.6k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_size_in_bytes(roaring::internal::run_container_s const*) Unexecuted instantiation: roaring.c:run_container_size_in_bytes roaring_array.c:run_container_size_in_bytes Line | Count | Source | 493 | 2.63k | const run_container_t *container) { | 494 | 2.63k | return run_container_serialized_size_in_bytes(container->n_runs); | 495 | 2.63k | } |
Unexecuted instantiation: containers.c:run_container_size_in_bytes Unexecuted instantiation: convert.c:run_container_size_in_bytes Unexecuted instantiation: mixed_intersection.c:run_container_size_in_bytes Unexecuted instantiation: mixed_union.c:run_container_size_in_bytes Unexecuted instantiation: mixed_equal.c:run_container_size_in_bytes Unexecuted instantiation: mixed_subset.c:run_container_size_in_bytes Unexecuted instantiation: mixed_negation.c:run_container_size_in_bytes Unexecuted instantiation: mixed_xor.c:run_container_size_in_bytes Unexecuted instantiation: mixed_andnot.c:run_container_size_in_bytes run.c:run_container_size_in_bytes Line | Count | Source | 493 | 72.0k | const run_container_t *container) { | 494 | 72.0k | return run_container_serialized_size_in_bytes(container->n_runs); | 495 | 72.0k | } |
Unexecuted instantiation: croaring_fuzzer.c:run_container_size_in_bytes Unexecuted instantiation: roaring64.c:run_container_size_in_bytes |
496 | | |
497 | | /** |
498 | | * Return true if the two containers have the same content. |
499 | | */ |
500 | | CROARING_ALLOW_UNALIGNED |
501 | | static inline bool run_container_equals(const run_container_t *container1, |
502 | 132 | const run_container_t *container2) { |
503 | 132 | if (container1->n_runs != container2->n_runs) { |
504 | 101 | return false; |
505 | 101 | } |
506 | 31 | return memequals(container1->runs, container2->runs, |
507 | 31 | container1->n_runs * sizeof(rle16_t)); |
508 | 132 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_equals(roaring::internal::run_container_s const*, roaring::internal::run_container_s const*) roaring.c:run_container_equals Line | Count | Source | 502 | 132 | const run_container_t *container2) { | 503 | 132 | if (container1->n_runs != container2->n_runs) { | 504 | 101 | return false; | 505 | 101 | } | 506 | 31 | return memequals(container1->runs, container2->runs, | 507 | 31 | container1->n_runs * sizeof(rle16_t)); | 508 | 132 | } |
Unexecuted instantiation: roaring_array.c:run_container_equals Unexecuted instantiation: containers.c:run_container_equals Unexecuted instantiation: convert.c:run_container_equals Unexecuted instantiation: mixed_intersection.c:run_container_equals Unexecuted instantiation: mixed_union.c:run_container_equals Unexecuted instantiation: mixed_equal.c:run_container_equals Unexecuted instantiation: mixed_subset.c:run_container_equals Unexecuted instantiation: mixed_negation.c:run_container_equals Unexecuted instantiation: mixed_xor.c:run_container_equals Unexecuted instantiation: mixed_andnot.c:run_container_equals Unexecuted instantiation: run.c:run_container_equals Unexecuted instantiation: croaring_fuzzer.c:run_container_equals Unexecuted instantiation: roaring64.c:run_container_equals |
509 | | |
510 | | /** |
511 | | * Return true if container1 is a subset of container2. |
512 | | */ |
513 | | bool run_container_is_subset(const run_container_t *container1, |
514 | | const run_container_t *container2); |
515 | | |
516 | | /** |
517 | | * Used in a start-finish scan that appends segments, for XOR and NOT |
518 | | */ |
519 | | |
520 | | void run_container_smart_append_exclusive(run_container_t *src, |
521 | | const uint16_t start, |
522 | | const uint16_t length); |
523 | | |
524 | | /** |
525 | | * The new container consists of a single run [start,stop). |
526 | | * It is required that stop>start, the caller is responsability for this check. |
527 | | * It is required that stop <= (1<<16), the caller is responsability for this |
528 | | * check. The cardinality of the created container is stop - start. Returns NULL |
529 | | * on failure |
530 | | */ |
531 | | static inline run_container_t *run_container_create_range(uint32_t start, |
532 | 91.0k | uint32_t stop) { |
533 | 91.0k | run_container_t *rc = run_container_create_given_capacity(1); |
534 | 91.0k | if (rc) { |
535 | 91.0k | rle16_t r; |
536 | 91.0k | r.value = (uint16_t)start; |
537 | 91.0k | r.length = (uint16_t)(stop - start - 1); |
538 | 91.0k | run_container_append_first(rc, r); |
539 | 91.0k | } |
540 | 91.0k | return rc; |
541 | 91.0k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_create_range(unsigned int, unsigned int) roaring.c:run_container_create_range Line | Count | Source | 532 | 91.0k | uint32_t stop) { | 533 | 91.0k | run_container_t *rc = run_container_create_given_capacity(1); | 534 | 91.0k | if (rc) { | 535 | 91.0k | rle16_t r; | 536 | 91.0k | r.value = (uint16_t)start; | 537 | 91.0k | r.length = (uint16_t)(stop - start - 1); | 538 | 91.0k | run_container_append_first(rc, r); | 539 | 91.0k | } | 540 | 91.0k | return rc; | 541 | 91.0k | } |
Unexecuted instantiation: roaring_array.c:run_container_create_range Unexecuted instantiation: containers.c:run_container_create_range Unexecuted instantiation: convert.c:run_container_create_range Unexecuted instantiation: mixed_intersection.c:run_container_create_range Unexecuted instantiation: mixed_union.c:run_container_create_range Unexecuted instantiation: mixed_equal.c:run_container_create_range Unexecuted instantiation: mixed_subset.c:run_container_create_range Unexecuted instantiation: mixed_negation.c:run_container_create_range Unexecuted instantiation: mixed_xor.c:run_container_create_range Unexecuted instantiation: mixed_andnot.c:run_container_create_range Unexecuted instantiation: run.c:run_container_create_range Unexecuted instantiation: croaring_fuzzer.c:run_container_create_range Unexecuted instantiation: roaring64.c:run_container_create_range |
542 | | |
543 | | /** |
544 | | * If the element of given rank is in this container, supposing that the first |
545 | | * element has rank start_rank, then the function returns true and sets element |
546 | | * accordingly. |
547 | | * Otherwise, it returns false and update start_rank. |
548 | | */ |
549 | | bool run_container_select(const run_container_t *container, |
550 | | uint32_t *start_rank, uint32_t rank, |
551 | | uint32_t *element); |
552 | | |
553 | | /* Compute the difference of src_1 and src_2 and write the result to |
554 | | * dst. It is assumed that dst is distinct from both src_1 and src_2. */ |
555 | | |
556 | | void run_container_andnot(const run_container_t *src_1, |
557 | | const run_container_t *src_2, run_container_t *dst); |
558 | | |
559 | | void run_container_offset(const run_container_t *c, container_t **loc, |
560 | | container_t **hic, uint16_t offset); |
561 | | |
562 | | /* Returns the smallest value (assumes not empty) */ |
563 | 16.9k | inline uint16_t run_container_minimum(const run_container_t *run) { |
564 | 16.9k | if (run->n_runs == 0) return 0; |
565 | 16.9k | return run->runs[0].value; |
566 | 16.9k | } |
567 | | |
568 | | /* Returns the largest value (assumes not empty) */ |
569 | 16.4k | inline uint16_t run_container_maximum(const run_container_t *run) { |
570 | 16.4k | if (run->n_runs == 0) return 0; |
571 | 16.4k | return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length; |
572 | 16.4k | } |
573 | | |
574 | | /* Returns the number of values equal or smaller than x */ |
575 | | int run_container_rank(const run_container_t *arr, uint16_t x); |
576 | | |
577 | | /* bulk version of run_container_rank(); return number of consumed elements */ |
578 | | uint32_t run_container_rank_many(const run_container_t *arr, |
579 | | uint64_t start_rank, const uint32_t *begin, |
580 | | const uint32_t *end, uint64_t *ans); |
581 | | |
582 | | /* Returns the index of x, if not exsist return -1 */ |
583 | | int run_container_get_index(const run_container_t *arr, uint16_t x); |
584 | | |
585 | | /* Returns the index of the first run containing a value at least as large as x, |
586 | | * or -1 */ |
587 | | inline int run_container_index_equalorlarger(const run_container_t *arr, |
588 | 0 | uint16_t x) { |
589 | 0 | int32_t index = interleavedBinarySearch(arr->runs, arr->n_runs, x); |
590 | 0 | if (index >= 0) return index; |
591 | 0 | index = -index - 2; // points to preceding run, possibly -1 |
592 | 0 | if (index != -1) { // possible match |
593 | 0 | int32_t offset = x - arr->runs[index].value; |
594 | 0 | int32_t le = arr->runs[index].length; |
595 | 0 | if (offset <= le) return index; |
596 | 0 | } |
597 | 0 | index += 1; |
598 | 0 | if (index < arr->n_runs) { |
599 | 0 | return index; |
600 | 0 | } |
601 | 0 | return -1; |
602 | 0 | } |
603 | | |
604 | | /* |
605 | | * Add all values in range [min, max] using hint. |
606 | | */ |
607 | | static inline void run_container_add_range_nruns(run_container_t *run, |
608 | | uint32_t min, uint32_t max, |
609 | | int32_t nruns_less, |
610 | 453 | int32_t nruns_greater) { |
611 | 453 | int32_t nruns_common = run->n_runs - nruns_less - nruns_greater; |
612 | 453 | if (nruns_common == 0) { |
613 | 147 | makeRoomAtIndex(run, (uint16_t)nruns_less); |
614 | 147 | run->runs[nruns_less].value = (uint16_t)min; |
615 | 147 | run->runs[nruns_less].length = (uint16_t)(max - min); |
616 | 306 | } else { |
617 | 306 | uint32_t common_min = run->runs[nruns_less].value; |
618 | 306 | uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value + |
619 | 306 | run->runs[nruns_less + nruns_common - 1].length; |
620 | 306 | uint32_t result_min = (common_min < min) ? common_min : min; |
621 | 306 | uint32_t result_max = (common_max > max) ? common_max : max; |
622 | | |
623 | 306 | run->runs[nruns_less].value = (uint16_t)result_min; |
624 | 306 | run->runs[nruns_less].length = (uint16_t)(result_max - result_min); |
625 | | |
626 | 306 | memmove(&(run->runs[nruns_less + 1]), |
627 | 306 | &(run->runs[run->n_runs - nruns_greater]), |
628 | 306 | nruns_greater * sizeof(rle16_t)); |
629 | 306 | run->n_runs = nruns_less + 1 + nruns_greater; |
630 | 306 | } |
631 | 453 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_add_range_nruns(roaring::internal::run_container_s*, unsigned int, unsigned int, int, int) roaring.c:run_container_add_range_nruns Line | Count | Source | 610 | 453 | int32_t nruns_greater) { | 611 | 453 | int32_t nruns_common = run->n_runs - nruns_less - nruns_greater; | 612 | 453 | if (nruns_common == 0) { | 613 | 147 | makeRoomAtIndex(run, (uint16_t)nruns_less); | 614 | 147 | run->runs[nruns_less].value = (uint16_t)min; | 615 | 147 | run->runs[nruns_less].length = (uint16_t)(max - min); | 616 | 306 | } else { | 617 | 306 | uint32_t common_min = run->runs[nruns_less].value; | 618 | 306 | uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value + | 619 | 306 | run->runs[nruns_less + nruns_common - 1].length; | 620 | 306 | uint32_t result_min = (common_min < min) ? common_min : min; | 621 | 306 | uint32_t result_max = (common_max > max) ? common_max : max; | 622 | | | 623 | 306 | run->runs[nruns_less].value = (uint16_t)result_min; | 624 | 306 | run->runs[nruns_less].length = (uint16_t)(result_max - result_min); | 625 | | | 626 | 306 | memmove(&(run->runs[nruns_less + 1]), | 627 | 306 | &(run->runs[run->n_runs - nruns_greater]), | 628 | 306 | nruns_greater * sizeof(rle16_t)); | 629 | 306 | run->n_runs = nruns_less + 1 + nruns_greater; | 630 | 306 | } | 631 | 453 | } |
Unexecuted instantiation: roaring_array.c:run_container_add_range_nruns Unexecuted instantiation: containers.c:run_container_add_range_nruns Unexecuted instantiation: convert.c:run_container_add_range_nruns Unexecuted instantiation: mixed_intersection.c:run_container_add_range_nruns Unexecuted instantiation: mixed_union.c:run_container_add_range_nruns Unexecuted instantiation: mixed_equal.c:run_container_add_range_nruns Unexecuted instantiation: mixed_subset.c:run_container_add_range_nruns Unexecuted instantiation: mixed_negation.c:run_container_add_range_nruns Unexecuted instantiation: mixed_xor.c:run_container_add_range_nruns Unexecuted instantiation: mixed_andnot.c:run_container_add_range_nruns Unexecuted instantiation: run.c:run_container_add_range_nruns Unexecuted instantiation: croaring_fuzzer.c:run_container_add_range_nruns Unexecuted instantiation: roaring64.c:run_container_add_range_nruns |
632 | | |
633 | | /** |
634 | | * Add all values in range [min, max]. This function is currently unused |
635 | | * and left as documentation. |
636 | | */ |
637 | | /*static inline void run_container_add_range(run_container_t* run, |
638 | | uint32_t min, uint32_t max) { |
639 | | int32_t nruns_greater = rle16_count_greater(run->runs, run->n_runs, max); |
640 | | int32_t nruns_less = rle16_count_less(run->runs, run->n_runs - |
641 | | nruns_greater, min); run_container_add_range_nruns(run, min, max, nruns_less, |
642 | | nruns_greater); |
643 | | }*/ |
644 | | |
645 | | /** |
646 | | * Shifts last $count elements either left (distance < 0) or right (distance > |
647 | | * 0) |
648 | | */ |
649 | | static inline void run_container_shift_tail(run_container_t *run, int32_t count, |
650 | 168 | int32_t distance) { |
651 | 168 | if (distance > 0) { |
652 | 0 | if (run->capacity < count + distance) { |
653 | 0 | run_container_grow(run, count + distance, true); |
654 | 0 | } |
655 | 0 | } |
656 | 168 | int32_t srcpos = run->n_runs - count; |
657 | 168 | int32_t dstpos = srcpos + distance; |
658 | 168 | memmove(&(run->runs[dstpos]), &(run->runs[srcpos]), |
659 | 168 | sizeof(rle16_t) * count); |
660 | 168 | run->n_runs += distance; |
661 | 168 | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_shift_tail(roaring::internal::run_container_s*, int, int) roaring.c:run_container_shift_tail Line | Count | Source | 650 | 168 | int32_t distance) { | 651 | 168 | if (distance > 0) { | 652 | 0 | if (run->capacity < count + distance) { | 653 | | run_container_grow(run, count + distance, true); | 654 | 0 | } | 655 | 0 | } | 656 | 168 | int32_t srcpos = run->n_runs - count; | 657 | 168 | int32_t dstpos = srcpos + distance; | 658 | 168 | memmove(&(run->runs[dstpos]), &(run->runs[srcpos]), | 659 | 168 | sizeof(rle16_t) * count); | 660 | 168 | run->n_runs += distance; | 661 | 168 | } |
Unexecuted instantiation: roaring_array.c:run_container_shift_tail Unexecuted instantiation: containers.c:run_container_shift_tail Unexecuted instantiation: convert.c:run_container_shift_tail Unexecuted instantiation: mixed_intersection.c:run_container_shift_tail Unexecuted instantiation: mixed_union.c:run_container_shift_tail Unexecuted instantiation: mixed_equal.c:run_container_shift_tail Unexecuted instantiation: mixed_subset.c:run_container_shift_tail Unexecuted instantiation: mixed_negation.c:run_container_shift_tail Unexecuted instantiation: mixed_xor.c:run_container_shift_tail Unexecuted instantiation: mixed_andnot.c:run_container_shift_tail Unexecuted instantiation: run.c:run_container_shift_tail Unexecuted instantiation: croaring_fuzzer.c:run_container_shift_tail Unexecuted instantiation: roaring64.c:run_container_shift_tail |
662 | | |
663 | | /** |
664 | | * Remove all elements in range [min, max] |
665 | | */ |
666 | | static inline void run_container_remove_range(run_container_t *run, |
667 | 1.77k | uint32_t min, uint32_t max) { |
668 | 1.77k | int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min); |
669 | 1.77k | int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max); |
670 | | |
671 | 1.77k | if (first >= 0 && min > run->runs[first].value && |
672 | 278 | max < ((uint32_t)run->runs[first].value + |
673 | 278 | (uint32_t)run->runs[first].length)) { |
674 | | // split this run into two adjacent runs |
675 | | |
676 | | // right subinterval |
677 | 41 | makeRoomAtIndex(run, (uint16_t)(first + 1)); |
678 | 41 | run->runs[first + 1].value = (uint16_t)(max + 1); |
679 | 41 | run->runs[first + 1].length = |
680 | 41 | (uint16_t)((run->runs[first].value + run->runs[first].length) - |
681 | 41 | (max + 1)); |
682 | | |
683 | | // left subinterval |
684 | 41 | run->runs[first].length = |
685 | 41 | (uint16_t)((min - 1) - run->runs[first].value); |
686 | | |
687 | 41 | return; |
688 | 41 | } |
689 | | |
690 | | // update left-most partial run |
691 | 1.73k | if (first >= 0) { |
692 | 589 | if (min > run->runs[first].value) { |
693 | 237 | run->runs[first].length = |
694 | 237 | (uint16_t)((min - 1) - run->runs[first].value); |
695 | 237 | first++; |
696 | 237 | } |
697 | 1.14k | } else { |
698 | 1.14k | first = -first - 1; |
699 | 1.14k | } |
700 | | |
701 | | // update right-most run |
702 | 1.73k | if (last >= 0) { |
703 | 561 | uint16_t run_max = run->runs[last].value + run->runs[last].length; |
704 | 561 | if (run_max > max) { |
705 | 337 | run->runs[last].value = (uint16_t)(max + 1); |
706 | 337 | run->runs[last].length = (uint16_t)(run_max - (max + 1)); |
707 | 337 | last--; |
708 | 337 | } |
709 | 1.17k | } else { |
710 | 1.17k | last = (-last - 1) - 1; |
711 | 1.17k | } |
712 | | |
713 | | // remove intermediate runs |
714 | 1.73k | if (first <= last) { |
715 | 168 | run_container_shift_tail(run, run->n_runs - (last + 1), |
716 | 168 | -(last - first + 1)); |
717 | 168 | } |
718 | 1.73k | } Unexecuted instantiation: croaring_fuzzer_cc.cc:roaring::internal::run_container_remove_range(roaring::internal::run_container_s*, unsigned int, unsigned int) roaring.c:run_container_remove_range Line | Count | Source | 667 | 1.77k | uint32_t min, uint32_t max) { | 668 | 1.77k | int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min); | 669 | 1.77k | int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max); | 670 | | | 671 | 1.77k | if (first >= 0 && min > run->runs[first].value && | 672 | 278 | max < ((uint32_t)run->runs[first].value + | 673 | 278 | (uint32_t)run->runs[first].length)) { | 674 | | // split this run into two adjacent runs | 675 | | | 676 | | // right subinterval | 677 | 41 | makeRoomAtIndex(run, (uint16_t)(first + 1)); | 678 | 41 | run->runs[first + 1].value = (uint16_t)(max + 1); | 679 | 41 | run->runs[first + 1].length = | 680 | 41 | (uint16_t)((run->runs[first].value + run->runs[first].length) - | 681 | 41 | (max + 1)); | 682 | | | 683 | | // left subinterval | 684 | 41 | run->runs[first].length = | 685 | 41 | (uint16_t)((min - 1) - run->runs[first].value); | 686 | | | 687 | 41 | return; | 688 | 41 | } | 689 | | | 690 | | // update left-most partial run | 691 | 1.73k | if (first >= 0) { | 692 | 589 | if (min > run->runs[first].value) { | 693 | 237 | run->runs[first].length = | 694 | 237 | (uint16_t)((min - 1) - run->runs[first].value); | 695 | 237 | first++; | 696 | 237 | } | 697 | 1.14k | } else { | 698 | 1.14k | first = -first - 1; | 699 | 1.14k | } | 700 | | | 701 | | // update right-most run | 702 | 1.73k | if (last >= 0) { | 703 | 561 | uint16_t run_max = run->runs[last].value + run->runs[last].length; | 704 | 561 | if (run_max > max) { | 705 | 337 | run->runs[last].value = (uint16_t)(max + 1); | 706 | 337 | run->runs[last].length = (uint16_t)(run_max - (max + 1)); | 707 | 337 | last--; | 708 | 337 | } | 709 | 1.17k | } else { | 710 | 1.17k | last = (-last - 1) - 1; | 711 | 1.17k | } | 712 | | | 713 | | // remove intermediate runs | 714 | 1.73k | if (first <= last) { | 715 | 168 | run_container_shift_tail(run, run->n_runs - (last + 1), | 716 | 168 | -(last - first + 1)); | 717 | 168 | } | 718 | 1.73k | } |
Unexecuted instantiation: roaring_array.c:run_container_remove_range Unexecuted instantiation: containers.c:run_container_remove_range Unexecuted instantiation: convert.c:run_container_remove_range Unexecuted instantiation: mixed_intersection.c:run_container_remove_range Unexecuted instantiation: mixed_union.c:run_container_remove_range Unexecuted instantiation: mixed_equal.c:run_container_remove_range Unexecuted instantiation: mixed_subset.c:run_container_remove_range Unexecuted instantiation: mixed_negation.c:run_container_remove_range Unexecuted instantiation: mixed_xor.c:run_container_remove_range Unexecuted instantiation: mixed_andnot.c:run_container_remove_range Unexecuted instantiation: run.c:run_container_remove_range Unexecuted instantiation: croaring_fuzzer.c:run_container_remove_range Unexecuted instantiation: roaring64.c:run_container_remove_range |
719 | | |
720 | | #ifdef __cplusplus |
721 | | } |
722 | | } |
723 | | } // extern "C" { namespace roaring { namespace internal { |
724 | | #endif |
725 | | |
726 | | #endif /* INCLUDE_CONTAINERS_RUN_H_ */ |