[bit-set-invertible] Plug in next_range()/previous_range()

This commit is contained in:
Behdad Esfahbod 2021-08-19 10:01:24 -06:00
parent f6aa37159b
commit c27f5b1288
1 changed files with 30 additions and 4 deletions

View File

@ -187,13 +187,39 @@ struct hb_bit_set_invertible_t
}
bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
{
/*XXX(inverted)*/
return s.next_range (first, last);
hb_codepoint_t i;
i = *last;
if (!next (&i))
{
*last = *first = INVALID;
return false;
}
/* TODO Speed up. */
*last = *first = i;
while (next (&i) && i == *last + 1)
(*last)++;
return true;
}
bool previous_range (hb_codepoint_t *first, hb_codepoint_t *last) const
{
/*XXX(inverted)*/
return s.previous_range (first, last);
hb_codepoint_t i;
i = *first;
if (!previous (&i))
{
*last = *first = INVALID;
return false;
}
/* TODO Speed up. */
*last = *first = i;
while (previous (&i) && i == *first - 1)
(*first)--;
return true;
}
unsigned int get_population () const