Geophysical Inversion and Modelling Library
v1.5.4
Loading...
Searching...
No Matches
function.hpp
Go to the documentation of this file.
1
7
8
#ifndef INCLUDE_KDTREE_ACCESSOR_HPP
9
#define INCLUDE_KDTREE_ACCESSOR_HPP
10
11
#include <cstddef>
12
13
namespace
KDTree
14
{
15
template
<
typename
_Val>
16
struct
_Bracket_accessor
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>
34
struct
squared_difference
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>
47
struct
squared_difference_counted
48
{
49
typedef
_Dist distance_type;
50
51
squared_difference_counted()
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 KDTree
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
*/
KDTree::_Bracket_accessor
Definition
function.hpp:17
KDTree::always_true
Definition
function.hpp:29
KDTree::squared_difference
Definition
function.hpp:35
source
core
src
kdtree++
function.hpp
Generated by
1.13.2