提交 11f1f413 编写于 作者: B Behdad Esfahbod

[set] Add is_subset

New API:
+hb_set_is_subset()
上级 45186b9b
......@@ -400,6 +400,19 @@ struct hb_set_t
return true;
}
inline bool is_subset (const hb_set_t *larger_set) const
{
if (get_population () > larger_set->get_population ())
return false;
hb_codepoint_t c = INVALID;
while (next (&c))
if (!larger_set->has (c))
return false;
return true;
}
template <class Op>
inline void process (const hb_set_t *other)
{
......
......@@ -267,11 +267,11 @@ hb_set_del_range (hb_set_t *set,
/**
* hb_set_is_equal:
* @set: a set.
* @other:
* @other: other set.
*
*
*
* Return value:
* Return value: %TRUE if the two sets are equal, %FALSE otherwise.
*
* Since: 0.9.7
**/
......@@ -282,6 +282,24 @@ hb_set_is_equal (const hb_set_t *set,
return set->is_equal (other);
}
/**
* hb_set_is_subset:
* @set: a set.
* @larger_set: other set.
*
*
*
* Return value: %TRUE if the @set is a subset of (or equal to) @larger_set, %FALSE otherwise.
*
* Since: 1.8.1
**/
hb_bool_t
hb_set_is_subset (const hb_set_t *set,
const hb_set_t *larger_set)
{
return set->is_subset (larger_set);
}
/**
* hb_set_set:
* @set: a set.
......
......@@ -104,6 +104,10 @@ HB_EXTERN hb_bool_t
hb_set_is_equal (const hb_set_t *set,
const hb_set_t *other);
HB_EXTERN hb_bool_t
hb_set_is_subset (const hb_set_t *set,
const hb_set_t *larger_set);
HB_EXTERN void
hb_set_set (hb_set_t *set,
const hb_set_t *other);
......
......@@ -146,8 +146,12 @@ test_set_algebra (void)
test_empty (s);
g_assert (!hb_set_is_equal (s, o));
g_assert (hb_set_is_subset (s, o));
g_assert (!hb_set_is_subset (o, s));
hb_set_set (s, o);
g_assert (hb_set_is_equal (s, o));
g_assert (hb_set_is_subset (s, o));
g_assert (hb_set_is_subset (o, s));
test_not_empty (s);
g_assert_cmpint (hb_set_get_population (s), ==, 2);
......
......@@ -178,12 +178,11 @@ test_subset_glyf_strip_hints_invalid (void)
hb_set_t *codepoints = hb_set_create();
const hb_codepoint_t text[] =
{
'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2',
'3', '@', '_', '%', '&', ')', '*', '$', '!'
};
int i;
for (i = 0; i < sizeof (text) / sizeof (hb_codepoint_t); i++)
{
'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2',
'3', '@', '_', '%', '&', ')', '*', '$', '!'
};
for (unsigned int i = 0; i < sizeof (text) / sizeof (hb_codepoint_t); i++)
{
hb_set_add (codepoints, text[i]);
// hb_set_add (codepoints_drop_hints, text[i]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册