--- src/libstddjb/bitarray_firstclear_skip.c | 22 ++++++++++++++++++++++ src/libstddjb/bitarray_firstset_skip.c | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/libstddjb/bitarray_firstclear_skip.c create mode 100644 src/libstddjb/bitarray_firstset_skip.c diff --git a/src/libstddjb/bitarray_firstclear_skip.c b/src/libstddjb/bitarray_firstclear_skip.c new file mode 100644 index 0000000..1361fb2 --- /dev/null +++ b/src/libstddjb/bitarray_firstclear_skip.c _at_@ -0,0 +1,22 @@ + +#include <skalibs/bitarray.h> + +unsigned int +bitarray_firstclear_skip (register unsigned char const *s, unsigned int max, unsigned int skip) +{ + unsigned int n = bitarray_div8(max) ; + register unsigned int i = bitarray_div8(skip) ; + if (i && s[i - 1] != 0xffU) + { + register unsigned int j = skip ; + skip = i << 3 ; + if (skip > max) skip = max ; + while ((j < skip) && bitarray_peek(s, j)) ++j ; + if (j < skip) return j ; + } + for (; i < n ; ++i) if (s[i] != 0xffU) break ; + if (i == n) return max ; + i <<= 3 ; + while ((i < max) && bitarray_peek(s, i)) ++i ; + return i ; +} diff --git a/src/libstddjb/bitarray_firstset_skip.c b/src/libstddjb/bitarray_firstset_skip.c new file mode 100644 index 0000000..5d77a0c --- /dev/null +++ b/src/libstddjb/bitarray_firstset_skip.c _at_@ -0,0 +1,22 @@ + +#include <skalibs/bitarray.h> + +unsigned int +bitarray_firstset_skip (register unsigned char const *s, unsigned int max, unsigned int skip) +{ + unsigned int n = bitarray_div8(max) ; + register unsigned int i = bitarray_div8(skip) ; + if (i && s[i - 1]) + { + register unsigned int j = skip ; + skip = i << 3 ; + if (skip > max) skip = max ; + while ((j < skip) && !bitarray_peek(s, j)) ++j ; + if (j < skip) return j ; + } + for (; i < n ; ++i) if (s[i]) break ; + if (i == n) return max ; + i <<= 3 ; + while ((i < max) && !bitarray_peek(s, i)) ++i ; + return i ; +} -- 2.6.4Received on Sun Dec 27 2015 - 18:03:23 UTC
This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC