LCOV - code coverage report
Current view: top level - vset/vtree/aspect - ad_lower_node.hpp (source / functions) Hit Total Coverage
Test: v-set-coverage.info Lines: 20 21 95.2 %
Date: 2019-09-12 Functions: 14 15 93.3 %

          Line data    Source code
       1             : //
       2             : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2012
       3             : //
       4             : // Copyright: See COPYING file that comes with this distribution
       5             : //
       6             : 
       7             : #ifndef VSET_VTREE_ASPECT_LOWER_NODE_HPP
       8             : #define VSET_VTREE_ASPECT_LOWER_NODE_HPP
       9             : 
      10             : #include <vset/vtree/aspect/tags.hpp>
      11             : 
      12             : namespace vset{ namespace vtree{
      13             : 
      14          29 : struct ad_lower_node
      15             : {
      16             :   template<typename T>
      17             :   typename T::container_type::iterator
      18       86917 :   operator()(T& t, const typename T::key_type& value)
      19             :   {
      20             :     typedef typename T::container_type container_type;
      21             :     typedef typename container_type::iterator iterator;
      22             : 
      23       86917 :     container_type& container = t.get_container();
      24       86917 :     iterator itr = container.lower_bound( std::make_pair(value, value ) );
      25             : 
      26       86917 :     if ( itr == container.end() && !container.empty() )
      27             :     {
      28       50500 :       itr = (++container.rbegin()).base();
      29             :     }
      30             : 
      31             :     // value < itr->first.first
      32      363623 :     if ( itr!=container.end() 
      33      260695 :       && itr!=container.begin()
      34       16011 :       && t.get_aspect().template get<_key_compare_>()(value, itr->first.first) )
      35             :     {
      36       14253 :       --itr;
      37             :     }
      38             : 
      39       86917 :     return  itr;
      40             :   }
      41             : 
      42             :   template<typename T>
      43             :   typename T::container_type::const_iterator
      44          14 :   operator()(const T& t, const typename T::key_type& value) const
      45             :   {
      46             :     typedef typename T::container_type container_type;
      47             :     typedef typename container_type::const_iterator const_iterator;
      48             : 
      49          14 :     const container_type& container = t.get_container();
      50          14 :     const_iterator itr = container.lower_bound( std::make_pair(value, value ) );
      51             : 
      52          14 :     if ( itr == container.cend() && !container.empty() )
      53             :     {
      54           6 :       itr = (++container.crbegin()).base();
      55             :     }
      56             : 
      57          66 :     if ( itr != container.cend()
      58          42 :       && itr != container.cbegin()
      59          10 :       && t.get_aspect().template get<_value_compare_>()(value, itr->first.first) )
      60             :     {
      61           0 :       --itr;
      62             :     }
      63             : 
      64          14 :     return itr;
      65             :   }
      66             : };
      67             : 
      68             : }}
      69             : 
      70             : #endif

Generated by: LCOV version 1.10