- Implemented map and multimap-like interfaces.

-  Refactored hashtable containers to reduce template instantiations.
This commit is contained in:
Ion Gaztañaga
2015-06-04 11:16:21 +02:00
parent 9ddcfa8e7d
commit 51de75799b
57 changed files with 5962 additions and 8937 deletions
+31 -1
View File
@@ -218,6 +218,7 @@ class bounded_allocator
assert(i < max_offset);
p.m_offset = i;
m_in_use[p.m_offset] = true;
++m_in_use_count;
return p;
}
@@ -227,6 +228,7 @@ class bounded_allocator
assert(n == 1);(void)n;
assert(m_in_use[p.m_offset]);
m_in_use[p.m_offset] = false;
--m_in_use_count;
}
// static methods
@@ -268,14 +270,31 @@ class bounded_allocator
friend class bounded_pointer< const T >;
static T* m_base;
static boost::container::vector< bool > m_in_use;
static std::size_t m_in_use_count;
}; // class bounded_allocator
template <class BoundedAllocator>
class bounded_allocator_scope
{
public:
bounded_allocator_scope()
{ BoundedAllocator::init(); }
~bounded_allocator_scope()
{
assert(BoundedAllocator::is_clear());
BoundedAllocator::destroy();
}
};
template < typename T >
T* bounded_allocator< T >::m_base = 0;
template < typename T >
boost::container::vector< bool > bounded_allocator< T >::m_in_use;
template < typename T >
std::size_t bounded_allocator< T >::m_in_use_count;
template < typename T >
class bounded_reference_cont
@@ -306,7 +325,7 @@ class bounded_reference_cont
using Base::operator[];
using Base::push_back;
bounded_reference_cont(size_t n = 0)
explicit bounded_reference_cont(size_t n = 0)
: Base(), m_allocator()
{
for (size_t i = 0; i < n; ++i){
@@ -338,6 +357,17 @@ class bounded_reference_cont
}
}
template <typename InputIterator>
void assign(InputIterator it_start, InputIterator it_end)
{
this->clear();
for (InputIterator it = it_start; it != it_end;){
pointer p = m_allocator.allocate(1);
new (p.raw()) val_type(*it++);
Base::push_back(*p);
}
}
~bounded_reference_cont()
{ clear(); }