[set] Add inverted to page_t::get_min/max()

This commit is contained in:
Behdad Esfahbod 2021-08-15 11:28:09 -06:00
parent 0dcd9b15d9
commit 4394ee1f1d
1 changed files with 12 additions and 6 deletions

View File

@ -186,18 +186,24 @@ struct hb_set_t
*codepoint = INVALID;
return false;
}
hb_codepoint_t get_min () const
hb_codepoint_t get_min (bool inverted = false) const
{
for (unsigned int i = 0; i < len (); i++)
if (v[i])
return i * ELT_BITS + elt_get_min (v[i]);
{
elt_t e = inverted ? ~v[i] : v[i];
if (e)
return i * ELT_BITS + elt_get_min (e);
}
return INVALID;
}
hb_codepoint_t get_max () const
hb_codepoint_t get_max (bool inverted = false) const
{
for (int i = len () - 1; i >= 0; i--)
if (v[i])
return i * ELT_BITS + elt_get_max (v[i]);
{
elt_t e = inverted ? ~v[i] : v[i];
if (e)
return i * ELT_BITS + elt_get_max (e);
}
return 0;
}