various fixes to bitset
* spot/misc/bitset.hh: here * tests/core/acc.cc: test it
This commit is contained in:
parent
74651c811d
commit
c6c085ab22
2 changed files with 18 additions and 5 deletions
|
|
@ -115,7 +115,7 @@ namespace spot
|
||||||
|
|
||||||
bool operator>=(const bitset& other) const
|
bool operator>=(const bitset& other) const
|
||||||
{
|
{
|
||||||
return other.operator>(*this);
|
return other.operator<=(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bitset operator<<(unsigned s) const
|
bitset operator<<(unsigned s) const
|
||||||
|
|
@ -295,19 +295,25 @@ namespace spot
|
||||||
|
|
||||||
unsigned highest() const
|
unsigned highest() const
|
||||||
{
|
{
|
||||||
unsigned res = 0;
|
unsigned res = (N-1)*8*sizeof(word_t);
|
||||||
for (auto v: data)
|
unsigned i = N;
|
||||||
|
while (i--)
|
||||||
{
|
{
|
||||||
|
auto v = data[i];
|
||||||
if (v == 0)
|
if (v == 0)
|
||||||
{
|
{
|
||||||
res += 8*sizeof(v);
|
res -= 8*sizeof(word_t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#ifdef __GNUC__
|
||||||
|
res += 8*sizeof(word_t) - __builtin_clz(v);
|
||||||
|
#else
|
||||||
while (v)
|
while (v)
|
||||||
{
|
{
|
||||||
++res;
|
++res;
|
||||||
v >>= 1;
|
v >>= 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return res-1;
|
return res-1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -315,7 +321,7 @@ namespace spot
|
||||||
|
|
||||||
unsigned lowest() const
|
unsigned lowest() const
|
||||||
{
|
{
|
||||||
unsigned res = 0;
|
unsigned res = 0U;
|
||||||
for (auto v: data)
|
for (auto v: data)
|
||||||
{
|
{
|
||||||
if (v == 0)
|
if (v == 0)
|
||||||
|
|
@ -323,11 +329,15 @@ namespace spot
|
||||||
res += 8*sizeof(v);
|
res += 8*sizeof(v);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#ifdef __GNUC__
|
||||||
|
res += __builtin_ctz(v);
|
||||||
|
#else
|
||||||
while ((v & 1) == 0)
|
while ((v & 1) == 0)
|
||||||
{
|
{
|
||||||
++res;
|
++res;
|
||||||
v >>= 1;
|
v >>= 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ int main()
|
||||||
auto m1 = spot::acc_cond::mark_t({0, 2});
|
auto m1 = spot::acc_cond::mark_t({0, 2});
|
||||||
auto m2 = spot::acc_cond::mark_t({0, 3});
|
auto m2 = spot::acc_cond::mark_t({0, 3});
|
||||||
auto m3 = spot::acc_cond::mark_t({2, 1});
|
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 = {};
|
spot::acc_cond::mark_t m0 = {};
|
||||||
std::cout << m0.max_set() << ' ' << m0.min_set() << '\n';
|
std::cout << m0.max_set() << ' ' << m0.min_set() << '\n';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue