MCPcopy Create free account
hub / github.com/FastLED/FastLED / find_run

Method find_run

src/fl/stl/bitset.h:289–310  ·  view source on GitHub ↗

Finds the first run of consecutive bits that match the test value. Returns the index of the first bit in the run, or -1 if no run found. @param test_value The value to search for (true or false) @param min_length Minimum length of the run (default: 1) @param offset Starting position to search from (default: 0)

Source from the content-addressed store, hash-verified

287 /// @param min_length Minimum length of the run (default: 1)
288 /// @param offset Starting position to search from (default: 0)
289 fl::i32 find_run(bool test_value, fl::u32 min_length, fl::u32 offset = 0) const FL_NOEXCEPT {
290 fl::u32 run_start = offset;
291 fl::u32 run_length = 0;
292
293 for (fl::u32 i = offset; i < N && run_length < min_length; ++i) {
294 bool current_bit = test(i);
295 if (current_bit != test_value) {
296 run_length = 0;
297 if (i + 1 < N) {
298 run_start = i + 1;
299 }
300 } else {
301 ++run_length;
302 }
303 }
304
305 if (run_length >= min_length) {
306 return static_cast<fl::i32>(run_start);
307 }
308
309 return -1; // No run found
310 }
311
312 /// Equality comparison
313 bool operator==(const bitset_fixed &other) const FL_NOEXCEPT {

Callers 2

findContiguousBlocksMethod · 0.80
FL_TEST_FILEFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected