[bit-set-invertible] Implement add_array / add_sorted_array / intersects

This commit is contained in:
Behdad Esfahbod 2021-08-18 21:20:54 -06:00
parent 0efa614c04
commit c39d2f7a76
1 changed files with 6 additions and 3 deletions

View File

@ -57,7 +57,7 @@ struct hb_bit_set_invertible_t
template <typename T> template <typename T>
void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T))
{ /*XXX(inverted)*/s.add_array (array, count, stride); } { inverted ? s.del_array (array, count, stride) : s.add_array (array, count, stride); }
template <typename T> template <typename T>
void add_array (const hb_array_t<const T>& arr) { add_array (&arr, arr.len ()); } void add_array (const hb_array_t<const T>& arr) { add_array (&arr, arr.len ()); }
@ -65,7 +65,7 @@ struct hb_bit_set_invertible_t
* Used for faster rejection of corrupt data. */ * Used for faster rejection of corrupt data. */
template <typename T> template <typename T>
bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T))
{ return /*XXX(inverted)*/s.add_sorted_array (array, count, stride); } { return inverted ? s.del_sorted_array (array, count, stride) : s.add_sorted_array (array, count, stride); }
template <typename T> template <typename T>
bool add_sorted_array (const hb_sorted_array_t<const T>& arr) { return add_sorted_array (&arr, arr.len ()); } bool add_sorted_array (const hb_sorted_array_t<const T>& arr) { return add_sorted_array (&arr, arr.len ()); }
@ -89,7 +89,10 @@ struct hb_bit_set_invertible_t
{ add_range (range.first, range.second); return *this; } { add_range (range.first, range.second); return *this; }
bool intersects (hb_codepoint_t first, hb_codepoint_t last) const bool intersects (hb_codepoint_t first, hb_codepoint_t last) const
{ return /*XXX(inverted)*/s.intersects (first, last); } {
hb_codepoint_t c = first - 1;
return next (&c) && c <= last;
}
void set (const hb_bit_set_invertible_t &other) { s.set (other.s); inverted = other.inverted; } void set (const hb_bit_set_invertible_t &other) { s.set (other.s); inverted = other.inverted; }