GteFeatureKey.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <GTEngineDEF.h>
11 
12 namespace gte
13 {
14 
15 template <int N, bool Ordered>
17 {
18 protected:
19  // Abstract base class with V[] uninitialized. The derived classes must
20  // set the V[] values accordingly.
21  //
22  // An ordered feature key has V[0] = min(V[]) with (V[0],V[1],...,V[N-1]) a
23  // permutation of N inputs with an even number of transpositions.
24  //
25  // An unordered feature key has V[0] < V[1] < ... < V[N-1].
26  //
27  // Note that the word 'order' is about the geometry of the feature, not
28  // the comparison order for any sorting.
29  FeatureKey();
30 
31 public:
32  bool operator<(FeatureKey const& key) const;
33  bool operator==(FeatureKey const& key) const;
34 
35  int V[N];
36 };
37 
38 
39 template <int N, bool Ordered>
41 {
42 }
43 
44 template <int N, bool Ordered>
46 {
47  for (int i = N - 1; i >= 0; --i)
48  {
49  if (V[i] < key.V[i])
50  {
51  return true;
52  }
53 
54  if (V[i] > key.V[i])
55  {
56  return false;
57  }
58  }
59  return false;
60 }
61 
62 template <int N, bool Ordered>
64 {
65  for (int i = 0; i < N; ++i)
66  {
67  if (V[i] != key.V[i])
68  {
69  return false;
70  }
71  }
72  return true;
73 }
74 
75 
76 }
bool operator<(FeatureKey const &key) const
Definition: GteFeatureKey.h:45
bool operator==(FeatureKey const &key) const
Definition: GteFeatureKey.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59