[set] Add hb_set_is_inverted()

This commit is contained in:
Behdad Esfahbod 2023-01-05 16:26:41 -07:00
parent e8ac0ef2fd
commit 5153218b41
6 changed files with 28 additions and 1 deletions

View File

@ -750,6 +750,7 @@ hb_set_intersect
hb_set_union
hb_set_symmetric_difference
hb_set_invert
hb_set_is_inverted
hb_set_is_equal
hb_set_is_subset
hb_set_next

View File

@ -74,6 +74,11 @@ struct hb_bit_set_invertible_t
inverted = !inverted;
}
bool is_inverted () const
{
return inverted;
}
bool is_empty () const
{
hb_codepoint_t v = INVALID;

View File

@ -491,6 +491,22 @@ hb_set_invert (hb_set_t *set)
set->invert ();
}
/**
* hb_set_is_inverted:
* @set: A set
*
* Returns whether the set is inverted.
*
* Return value: `true` if the set is inverted, `false` otherwise
*
* Since: REPLACEME
**/
hb_bool_t
hb_set_is_inverted (const hb_set_t *set)
{
return set->is_inverted ();
}
/**
* hb_set_get_population:
* @set: A set

View File

@ -97,6 +97,9 @@ hb_set_is_empty (const hb_set_t *set);
HB_EXTERN void
hb_set_invert (hb_set_t *set);
HB_EXTERN hb_bool_t
hb_set_is_inverted (const hb_set_t *set);
HB_EXTERN hb_bool_t
hb_set_has (const hb_set_t *set,
hb_codepoint_t codepoint);

View File

@ -79,6 +79,7 @@ struct hb_sparseset_t
void reset () { s.reset (); }
void clear () { s.clear (); }
void invert () { s.invert (); }
bool is_inverted () const { return s.is_inverted (); }
bool is_empty () const { return s.is_empty (); }
uint32_t hash () const { return s.hash (); }

View File

@ -132,7 +132,8 @@ main (int argc, char **argv)
assert (last == 4);
assert (!s.previous_range (&start, &last));
/* Inverted set returns true for invalid value. */
assert (s.is_inverted ());
/* Inverted set returns true for invalid value; oh well. */
assert (s.has (HB_SET_VALUE_INVALID));
}