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
This commit is contained in:
Maximilien Colange 2018-05-25 11:42:29 +02:00
parent 88a6bd82a3
commit 5b9088006c
2 changed files with 17 additions and 5 deletions

View file

@ -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;

View file

@ -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)