LCOV - code coverage report
Current view: top level - vset/vtree/aspect - ad_defrag_container.hpp (source / functions) Hit Total Coverage
Test: v-set-coverage.info Lines: 15 15 100.0 %
Date: 2019-09-12 Functions: 7 8 87.5 %

          Line data    Source code
       1             : //
       2             : // Author: Dmitry Saprykin <saprykin.dmitry@gmail.com>, (C) 2013
       3             : //
       4             : // Copyright: See COPYING file that comes with this distribution
       5             : //
       6             : 
       7             : #ifndef VSET_VTREE_ASPECT_AD_DEFRAG_CONTAINER_HPP
       8             : #define VSET_VTREE_ASPECT_AD_DEFRAG_CONTAINER_HPP
       9             : 
      10             : #include <vset/vtree/aspect/tags.hpp>
      11             : 
      12             : namespace vset{ namespace vtree{
      13             : 
      14          29 : struct ad_defrag_container
      15             : {
      16             :   template<typename T>
      17             :   struct helper
      18             :   {
      19             :     typedef typename T::container_type container_type;
      20             :     typedef typename container_type::iterator iterator;
      21             :   };
      22             : 
      23             :   template<typename T>
      24       16851 :   void operator()(T& t, typename T::iterator block_itr)
      25             :   {
      26             :     typedef typename helper<T>::container_type container_type;
      27             :     typedef typename container_type::iterator container_iterator;
      28             : 
      29       16851 :     container_type& container = t.get_container();
      30       16851 :     container_iterator itr = block_itr.get_source_iterator();
      31       16851 :     if( itr != container.end() )
      32             :     {
      33       14571 :       container_iterator next = itr;
      34       14571 :       next++;
      35       14571 :       if( next != container.end() )
      36             :       {
      37        6396 :         if( 2 * (itr->second->size() + next->second->size()) <= itr->second->capacity() )
      38             :         {
      39        2451 :           for(unsigned int i = 0; i < next->second->size(); i++)
      40             :           {
      41        2432 :             itr->second->push_back(next->second->at(i), t.get_aspect().template get<_compare_>());
      42             :           }
      43          19 :           container.erase( next );
      44          19 :           t.get_allocator().deallocate(next->second, 1);
      45          19 :           t.get_aspect().template get<_update_node_key_>()(t, itr);
      46             :         }
      47             :       }
      48             :     }
      49       16851 :   }
      50             : };
      51             :   
      52             : }}
      53             : 
      54             : #endif

Generated by: LCOV version 1.10