cheshirekow  v0.1.0
Key.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_KD_TREE_EUCLIDEAN_KEY_H_
28 #define MPBLOCKS_KD_TREE_EUCLIDEAN_KEY_H_
29 
30 
31 
32 namespace mpblocks {
33 namespace kd_tree {
34 namespace euclidean {
35 
36 
37 template <class Traits>
38 struct Key
39 {
40  typedef typename Traits::Format_t Format_t;
41  typedef typename Traits::Node Node_t;
42  typedef Key<Traits> Key_t;
43 
46 
47  struct Compare
48  {
49  bool operator()( const Key_t& a, const Key_t& b )
50  {
51  if( a.d2 < b.d2 )
52  return true;
53  if( b.d2 < a.d2 )
54  return false;
55  return (a.n < b.n );
56  }
57  };
58 };
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 } // namespace euclidean
71 } // namespace kd_tree
72 } // namespace mpblocks
73 
74 
75 
76 
77 
78 
79 #endif // SEARCHKEY_H_
bool operator()(const Key_t &a, const Key_t &b)
Definition: Key.h:49
the node class must be defined in traits since it uses the CTRP, it must derive from kd_tree::Node<Tr...
Definition: Traits.h:49
Traits::Format_t Format_t
Definition: Key.h:40
double Format_t
number format (i.e. double, float)
Definition: Traits.h:38