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_AD_FIND_HPP
8 : #define VSET_VTREE_ASPECT_AD_FIND_HPP
9 :
10 : #include <vset/vtree/aspect/tags.hpp>
11 : #include <algorithm>
12 :
13 : namespace vset{ namespace vtree{
14 :
15 29 : struct ad_find
16 : {
17 : template<typename T>
18 : typename T::iterator
19 10014 : operator()(T& t, const typename T::key_type& value)
20 : {
21 10014 : typename T::iterator itr = t.get_aspect().template get<_lower_bound_>()(t, value);
22 :
23 10014 : if ( itr == t.end() )
24 : {
25 2081 : return t.end();
26 : }
27 :
28 15866 : if ( t.get_aspect().template get<_key_compare_>()(*itr, value)
29 7933 : || t.get_aspect().template get<_key_compare_>()(value, *itr) )
30 : {
31 7929 : return t.end();
32 : }
33 :
34 4 : return itr;
35 : }
36 : };
37 :
38 : }}
39 :
40 : #endif
|