From 62c3e111fce0ad34960871134c2eb6da572df303 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 25 May 2012 13:48:00 -0400 Subject: [PATCH] Add set symmetric difference --- src/hb-set-private.hh | 5 +++++ src/hb-set.cc | 7 +++++++ src/hb-set.h | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 717e5304d..df96b9903 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -102,6 +102,11 @@ struct _hb_set_t for (unsigned int i = 0; i < ELTS; i++) elts[i] &= ~other->elts[i]; } + inline void symmetric_difference (const hb_set_t *other) + { + for (unsigned int i = 0; i < ELTS; i++) + elts[i] ^= other->elts[i]; + } inline hb_codepoint_t get_min (void) const { for (unsigned int i = 0; i < ELTS; i++) diff --git a/src/hb-set.cc b/src/hb-set.cc index 0e8addec0..7103bcd1f 100644 --- a/src/hb-set.cc +++ b/src/hb-set.cc @@ -164,6 +164,13 @@ hb_set_subtract (hb_set_t *set, set->subtract (other); } +void +hb_set_symmetric_difference (hb_set_t *set, + hb_set_t *other) +{ + set->symmetric_difference (other); +} + hb_codepoint_t hb_set_min (hb_set_t *set) { diff --git a/src/hb-set.h b/src/hb-set.h index 35c77b8f0..38bb84b5f 100644 --- a/src/hb-set.h +++ b/src/hb-set.h @@ -105,9 +105,15 @@ void hb_set_subtract (hb_set_t *set, hb_set_t *other); +void +hb_set_symmetric_difference (hb_set_t *set, + hb_set_t *other); + +/* Undefined if set empty */ hb_codepoint_t hb_set_min (hb_set_t *set); +/* Undefined if set empty */ hb_codepoint_t hb_set_max (hb_set_t *set);