FeatureKey.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <algorithm>
  9. #include <array>
  10. namespace WwiseGTE
  11. {
  12. template <int N, bool Ordered>
  13. class FeatureKey
  14. {
  15. protected:
  16. // Abstract base class with V[] uninitialized. The derived classes
  17. // must set the V[] values accordingly.
  18. //
  19. // An ordered feature key has V[0] = min(V[]) with
  20. // (V[0],V[1],...,V[N-1]) a permutation of N inputs with an even
  21. // number of transpositions.
  22. //
  23. // An unordered feature key has V[0] < V[1] < ... < V[N-1].
  24. //
  25. // Note that the word 'order' is about the geometry of the feature, not
  26. // the comparison order for any sorting.
  27. FeatureKey() = default;
  28. public:
  29. bool operator==(FeatureKey const& key) const
  30. {
  31. return V == key.V;
  32. }
  33. bool operator!=(FeatureKey const& key) const
  34. {
  35. return V != key.V;
  36. }
  37. bool operator<(FeatureKey const& key) const
  38. {
  39. return V < key.V;
  40. }
  41. bool operator<=(FeatureKey const& key) const
  42. {
  43. return V <= key.V;
  44. }
  45. bool operator>(FeatureKey const& key) const
  46. {
  47. return V > key.V;
  48. }
  49. bool operator>=(FeatureKey const& key) const
  50. {
  51. return V >= key.V;
  52. }
  53. std::array<int, N> V;
  54. };
  55. }