xc
function.hpp
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_KDTREE_ACCESSOR_HPP
9 #define INCLUDE_KDTREE_ACCESSOR_HPP
10 
11 #include <cstddef>
12 
13 namespace kd_tree
14 {
15  template <typename _Val>
17  {
18  typedef typename _Val::value_type result_type;
19 
20  result_type
21  operator()(_Val const& V, size_t const N) const
22  {
23  return V[N];
24  }
25  };
26 
27  template <typename _Tp>
28  struct always_true
29  {
30  bool operator() (const _Tp& ) const { return true; }
31  };
32 
33  template <typename _Tp, typename _Dist>
35  {
36  typedef _Dist distance_type;
37 
38  distance_type
39  operator() (const _Tp& __a, const _Tp& __b) const
40  {
41  distance_type d=__a - __b;
42  return d*d;
43  }
44  };
45 
46  template <typename _Tp, typename _Dist>
48  {
49  typedef _Dist distance_type;
50 
52  : _M_count(0)
53  { }
54 
55  void reset ()
56  { _M_count = 0; }
57 
58  long&
59  count () const
60  { return _M_count; }
61 
62  distance_type
63  operator() (const _Tp& __a, const _Tp& __b) const
64  {
65  distance_type d=__a - __b;
66  ++_M_count;
67  return d*d;
68  }
69 
70  private:
71  mutable long _M_count;
72  };
73 
74 } // namespace kd_tree
75 
76 #endif // include guard
77 
78 /* COPYRIGHT --
79  *
80  * This file is part of libkdtree++, a C++ template KD-Tree sorting container.
81  * libkdtree++ is (c) 2004-2007 Martin F. Krafft <libkdtree@pobox.madduck.net>
82  * and Sylvain Bougerel <sylvain.bougerel.devel@gmail.com> distributed under the
83  * terms of the Artistic License 2.0. See the ./COPYING file in the source tree
84  * root for more information.
85  *
86  * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
87  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
88  * OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
89  */
Definition: function.hpp:47
Definition: function.hpp:34
Definition: function.hpp:28
Definition: function.hpp:16
Definition: allocator.hpp:14