Commit c6c085ab authored by Maximilien Colange's avatar Maximilien Colange
Browse files

various fixes to bitset

* spot/misc/bitset.hh: here
* tests/core/acc.cc: test it
parent 74651c81
......@@ -115,7 +115,7 @@ namespace spot
bool operator>=(const bitset& other) const
{
return other.operator>(*this);
return other.operator<=(*this);
}
bitset operator<<(unsigned s) const
......@@ -295,19 +295,25 @@ namespace spot
unsigned highest() const
{
unsigned res = 0;
for (auto v: data)
unsigned res = (N-1)*8*sizeof(word_t);
unsigned i = N;
while (i--)
{
auto v = data[i];
if (v == 0)
{
res += 8*sizeof(v);
res -= 8*sizeof(word_t);
continue;
}
#ifdef __GNUC__
res += 8*sizeof(word_t) - __builtin_clz(v);
#else
while (v)
{
++res;
v >>= 1;
}
#endif
return res-1;
}
return 0;
......@@ -315,7 +321,7 @@ namespace spot
unsigned lowest() const
{
unsigned res = 0;
unsigned res = 0U;
for (auto v: data)
{
if (v == 0)
......@@ -323,11 +329,15 @@ namespace spot
res += 8*sizeof(v);
continue;
}
#ifdef __GNUC__
res += __builtin_ctz(v);
#else
while ((v & 1) == 0)
{
++res;
v >>= 1;
}
#endif
return res;
}
return 0;
......
......@@ -64,6 +64,9 @@ int main()
auto m1 = spot::acc_cond::mark_t({0, 2});
auto m2 = spot::acc_cond::mark_t({0, 3});
auto m3 = spot::acc_cond::mark_t({2, 1});
auto m4 = spot::acc_cond::mark_t({0, SPOT_NB_ACC-2});
if (!(m4.min_set() == 1 && m4.max_set() == SPOT_NB_ACC-1))
return 1;
spot::acc_cond::mark_t m0 = {};
std::cout << m0.max_set() << ' ' << m0.min_set() << '\n';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment