Add / modify set API a bit
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 43cf925..c736b69 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -147,7 +147,7 @@
inline void clear (void) {
memset (elts, 0, sizeof elts);
}
- inline bool empty (void) const {
+ inline bool is_empty (void) const {
for (unsigned int i = 0; i < ARRAY_LENGTH (elts); i++)
if (elts[i])
return false;
@@ -161,6 +161,7 @@
}
inline void add_range (hb_codepoint_t a, hb_codepoint_t b)
{
+ /* TODO Speedup */
for (unsigned int i = a; i < b + 1; i++)
add (i);
}
@@ -169,6 +170,12 @@
if (unlikely (g > MAX_G)) return;
elt (g) &= ~mask (g);
}
+ inline void del_range (hb_codepoint_t a, hb_codepoint_t b)
+ {
+ /* TODO Speedup */
+ for (unsigned int i = a; i < b + 1; i++)
+ del (i);
+ }
inline bool has (hb_codepoint_t g) const
{
if (unlikely (g > MAX_G)) return false;
@@ -185,7 +192,7 @@
return true;
return false;
}
- inline bool equal (const hb_set_t *other) const
+ inline bool is_equal (const hb_set_t *other) const
{
for (unsigned int i = 0; i < ELTS; i++)
if (elts[i] != other->elts[i])
@@ -217,7 +224,7 @@
for (unsigned int i = 0; i < ELTS; i++)
elts[i] ^= other->elts[i];
}
- inline bool next (hb_codepoint_t *codepoint)
+ inline bool next (hb_codepoint_t *codepoint) const
{
if (unlikely (*codepoint == SENTINEL)) {
hb_codepoint_t i = get_min ();
@@ -234,6 +241,28 @@
}
return false;
}
+ inline bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
+ {
+ hb_codepoint_t i;
+
+ i = *last;
+ if (!next (&i))
+ return false;
+
+ *last = *first = i;
+ while (next (&i) && i == *last + 1)
+ (*last)++;
+
+ return true;
+ }
+
+ inline unsigned int get_population (void) const
+ {
+ unsigned int count = 0;
+ for (unsigned int i = 0; i < ELTS; i++)
+ count += _hb_popcount32 (elts[i]);
+ return count;
+ }
inline hb_codepoint_t get_min (void) const
{
for (unsigned int i = 0; i < ELTS; i++)