From 5b9088006c016ab7f9d2b93ad4f37b4a59369c8b Mon Sep 17 00:00:00 2001 From: Maximilien Colange Date: Fri, 25 May 2018 11:42:29 +0200 Subject: [PATCH] a few improvements to mark_t * spot/misc/bitset.hh: add methods set() and clear() * spot/twa/acc.hh: deprecate comparison of mark_t with unsigned, and rely more on biset for efficiency --- spot/misc/bitset.hh | 12 ++++++++++++ spot/twa/acc.hh | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/spot/misc/bitset.hh b/spot/misc/bitset.hh index 77e3e9684..5dac1af72 100644 --- a/spot/misc/bitset.hh +++ b/spot/misc/bitset.hh @@ -124,6 +124,18 @@ namespace spot return other.operator<=(*this); } + void set(unsigned s) + { + SPOT_ASSERT(s < 8*N*sizeof(word_t)); + data[s / (8*sizeof(word_t))] |= 1U << (s % (8*sizeof(word_t))); + } + + void clear(unsigned s) + { + SPOT_ASSERT(s < 8*N*sizeof(word_t)); + data[s / (8*sizeof(word_t))] &= ~(1U << (s % (8*sizeof(word_t)))); + } + bitset operator<<(unsigned s) const { bitset r = *this; diff --git a/spot/twa/acc.hh b/spot/twa/acc.hh index 28e4b439e..d0c2e4c5c 100644 --- a/spot/twa/acc.hh +++ b/spot/twa/acc.hh @@ -96,9 +96,7 @@ namespace spot static mark_t all() { - mark_t res({}); - res.id -= 1; - return res; + return mark_t(_value_t::mone()); } size_t hash() const noexcept @@ -107,12 +105,14 @@ namespace spot return h(id); } + SPOT_DEPRECATED("compare mark_t to mark_t, not to unsigned") bool operator==(unsigned o) const { SPOT_ASSERT(o == 0U); return !id; } + SPOT_DEPRECATED("compare mark_t to mark_t, not to unsigned") bool operator!=(unsigned o) const { SPOT_ASSERT(o == 0U); @@ -161,12 +161,12 @@ namespace spot void set(unsigned u) { - id |= (_value_t::one() << u); + id.set(u); } void clear(unsigned u) { - id &= ~(_value_t::one() << u); + id.clear(u); } mark_t& operator&=(mark_t r)