add a pool allocator for STL containers
* spot/priv/allocator.hh, spot/priv/Makefile.am: add a STL-compliant allocator based on spot::fixed_size_pool * spot/misc/fixpool.hh, spot/misc/fixpool.cc, spot/misc/Makefile.am: refactor the existing spot::fixed_size_pool * spot/ltsmin/ltsmin.cc, spot/twa/twaproduct.cc: reflect changes in the interface of spot::fixed_size_pool * tests/core/mempool.cc: test the new allocator
This commit is contained in:
parent
3fe74f1cb9
commit
c9131aee72
8 changed files with 258 additions and 21 deletions
|
|
@ -23,6 +23,9 @@
|
|||
|
||||
#include <spot/misc/fixpool.hh>
|
||||
#include <spot/misc/mspool.hh>
|
||||
#include <spot/priv/allocator.hh>
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
@ -154,6 +157,32 @@ int main()
|
|||
c->incr();
|
||||
// no delete: valgrind should find a leak
|
||||
}
|
||||
{
|
||||
std::set<int, std::less<int>, spot::pool_allocator<int>> s;
|
||||
s.insert(1);
|
||||
s.insert(2);
|
||||
s.insert(1);
|
||||
s.erase(1);
|
||||
s.insert(3);
|
||||
s.insert(4);
|
||||
|
||||
s.clear();
|
||||
|
||||
auto t = s;
|
||||
t.insert(5);
|
||||
t.insert(6);
|
||||
|
||||
std::swap(s, t);
|
||||
|
||||
s.erase(5);
|
||||
s.erase(6);
|
||||
|
||||
if (s != t)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue