Commit ec83e60b authored by Etienne Renault's avatar Etienne Renault

bitvec: remove useless methods

* spot/misc/bitvect.hh, tests/core/bitvect.cc,
tests/core/bitvect.test: here.
parent 43ec36cd
...@@ -140,50 +140,6 @@ namespace spot ...@@ -140,50 +140,6 @@ namespace spot
return (size_ + bpb - 1) / bpb; return (size_ + bpb - 1) / bpb;
} }
/// Append one bit.
void emplace_back(bool val)
{
if (size() == capacity())
grow();
size_t pos = size_++;
if (val)
set(pos);
else
clear(pos);
}
/// \brief Append the lowest \a count bits of \a data.
void emplace_back(block_t data, unsigned count)
{
if (size() + count > capacity())
grow();
const size_t bpb = 8 * sizeof(block_t);
// Clear the higher bits.
if (count != bpb)
data &= (1UL << count) - 1;
size_t n = size() % bpb;
size_t i = size_ / bpb;
size_ += count;
if (n == 0) // Aligned on block_t boundary
{
storage_[i] = data;
}
else // Only (bpb-n) bits free in this block.
{
// Take the lower bpb-n bits of data...
block_t mask = (1UL << (bpb - n)) - 1;
block_t data1 = (data & mask) << n;
mask <<= n;
// ... write them on the higher bpb-n bits of last block.
storage_[i] = (storage_[i] & ~mask) | data1;
// Write the remaining bits in the next block.
if (bpb - n < count)
storage_[i + 1] = data >> (bpb - n);
}
}
size_t size() const size_t size() const
{ {
return size_; return size_;
...@@ -392,57 +348,6 @@ namespace spot ...@@ -392,57 +348,6 @@ namespace spot
return !(other < *this); return !(other < *this);
} }
// \brief Extract a range of bits.
//
// Build a new bit-vector using the bits from \a begin (included)
// to \a end (excluded).
bitvect* extract_range(size_t begin, size_t end)
{
SPOT_ASSERT(begin <= end);
SPOT_ASSERT(end <= size());
size_t count = end - begin;
bitvect* res = make_bitvect(count);
res->make_empty();
if (end == begin)
return res;
const size_t bpb = 8 * sizeof(bitvect::block_t);
size_t indexb = begin / bpb;
unsigned bitb = begin % bpb;
size_t indexe = (end - 1) / bpb;
if (indexb == indexe)
{
block_t data = storage_[indexb];
data >>= bitb;
res->emplace_back(data, count);
}
else
{
block_t data = storage_[indexb];
data >>= bitb;
res->emplace_back(data, bpb - bitb);
count -= bpb - bitb;
while (count >= bpb)
{
++indexb;
res->emplace_back(storage_[indexb], bpb);
count -= bpb;
SPOT_ASSERT(indexb != indexe || count == 0);
}
if (count > 0)
{
++indexb;
SPOT_ASSERT(indexb == indexe);
SPOT_ASSERT(count == end % bpb);
res->emplace_back(storage_[indexb], count);
}
}
return res;
}
friend SPOT_API bitvect* make_bitvect(size_t bitcount); friend SPOT_API bitvect* make_bitvect(size_t bitcount);
/// Print a bitvect. /// Print a bitvect.
......
...@@ -67,37 +67,6 @@ int main() ...@@ -67,37 +67,6 @@ int main()
std::cout << "subset? " << w->is_subset_of(*x) std::cout << "subset? " << w->is_subset_of(*x)
<< ' ' << v->is_subset_of(*w) << '\n'; << ' ' << v->is_subset_of(*w) << '\n';
for (size_t i = 0; i < 30; ++i)
w->emplace_back((i & 3) == 0);
ECHO(w);
*x &= *w;
ECHO(x);
x->set_all();
ECHO(x);
ruler();
w->emplace_back(0x09, 4);
ECHO(w);
spot::bitvect* y = w->extract_range(0, 71);
ECHO(y);
delete y;
y = w->extract_range(0, 64);
ECHO(y);
delete y;
y = w->extract_range(64, 75);
ECHO(y);
delete y;
y = w->extract_range(0, 75);
ECHO(y);
delete y;
y = w->extract_range(7, 64);
ECHO(y);
delete y;
y = w->extract_range(7, 72);
ECHO(y);
delete y;
delete v; delete v;
delete w; delete w;
delete x; delete x;
...@@ -115,8 +84,6 @@ int main() ...@@ -115,8 +84,6 @@ int main()
ruler(); ruler();
for (size_t i = 0; i < 12; ++i)
a->at(4).emplace_back((i & 2) == 0);
a->at(6) = a->at(4); a->at(6) = a->at(4);
a->at(8) = a->at(7); a->at(8) = a->at(7);
a->at(6) ^= a->at(8); a->at(6) ^= a->at(8);
......
#!/bin/sh #!/bin/sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2013, 2015 Laboratoire de Recherche et Développement # Copyright (C) 2013, 2015, 2016 Laboratoire de Recherche et Développement
# de l'Epita (LRDE). # de l'Epita (LRDE).
# #
# This file is part of Spot, a model checking library. # This file is part of Spot, a model checking library.
...@@ -44,20 +44,6 @@ w: 000000000010110000000000000000100000000001 ...@@ -44,20 +44,6 @@ w: 000000000010110000000000000000100000000001
x: 000000000000000000000000000000000000000000000000000000000000100000000010000 x: 000000000000000000000000000000000000000000000000000000000000100000000010000
x: 000000000010110000000000000000100000000001000000000000000000100000000010000 x: 000000000010110000000000000000100000000001000000000000000000100000000010000
subset? 1 0 subset? 1 0
w: 000000000010110000000000000000100000000001100010001000100010001000100010
x: 000000000010110000000000000000100000000001000000000000000000000000000010000
x: 111111111111111111111111111111111111111111111111111111111111111111111111111
0_________1_________2_________3_________4_________5_________6_________7_____
0123456789012345678901234567890123456789012345678901234567890123456789012345
w: 0000000000101100000000000000001000000000011000100010001000100010001000101001
y: 00000000001011000000000000000010000000000110001000100010001000100010001
y: 0000000000101100000000000000001000000000011000100010001000100010
y: 00100010100
y: 000000000010110000000000000000100000000001100010001000100010001000100010100
y: 000101100000000000000001000000000011000100010001000100010
y: 00010110000000000000000100000000001100010001000100010001000100010
0_________1_________2_________3_________4_________5_________6_________7_____ 0_________1_________2_________3_________4_________5_________6_________7_____
0123456789012345678901234567890123456789012345678901234567890123456789012345 0123456789012345678901234567890123456789012345678901234567890123456789012345
...@@ -80,13 +66,13 @@ y: 00010110000000000000000100000000001100010001000100010001000100010 ...@@ -80,13 +66,13 @@ y: 00010110000000000000000100000000001100010001000100010001000100010
1: 110011001100110011001100110011001100110011001100110011001100 1: 110011001100110011001100110011001100110011001100110011001100
2: 001100110011001100110011001100110011001100110011001100110011 2: 001100110011001100110011001100110011001100110011001100110011
3: 001100110011001100110011001100110011001100110011001100110011 3: 001100110011001100110011001100110011001100110011001100110011
4: 110011001100110011001100110011001100110011001100110011001100110011001100 4: 110011001100110011001100110011001100110011001100110011001100
5: 110011001100110011001100110011001100110011001100110011001100 5: 110011001100110011001100110011001100110011001100110011001100
6: 111111111111111111111111111111111111111111111111111111111111110011001100 6: 111111111111111111111111111111111111111111111111111111111111
7: 001100110011001100110011001100110011001100110011001100110011 7: 001100110011001100110011001100110011001100110011001100110011
8: 001100110011001100110011001100110011001100110011001100110011 8: 001100110011001100110011001100110011001100110011001100110011
9: 110011001100110011001100110011001100110011001100110011001100 9: 110011001100110011001100110011001100110011001100110011001100
Comp: 1011010 Comp: 1011000
EOF EOF
diff expected stderr diff expected stderr
Markdown is supported
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