DGtal  0.9.2
KhalimskyCellHashFunctions.h
1 
17 #pragma once
18 
29 #if defined(KhalimskyCellHashFunctions_RECURSES)
30 #error Recursive header files inclusion detected in KhalimskyCellHashFunctions.h
31 #else // defined(KhalimskyCellHashFunctions_RECURSES)
32 
33 #define KhalimskyCellHashFunctions_RECURSES
34 
35 #if !defined KhalimskyCellHashFunctions_h
36 
37 #define KhalimskyCellHashFunctions_h
38 
40 // Inclusions
41 #include <iostream>
42 #include "DGtal/base/Common.h"
43 #include "DGtal/topology/KhalimskySpaceND.h"
44 #include <boost/functional/hash.hpp>
46 
47 
48 namespace std {
54  template < DGtal::Dimension dim,
55  typename TInteger >
56  struct hash< DGtal::KhalimskyCell< dim, TInteger > >
57  {
59  {
60  auto const& p = pp.preCell();
61  return boost::hash_range(p.coordinates.begin(), p.coordinates.end());
62  }
63  };
64 
70  template < DGtal::Dimension dim,
71  typename TInteger >
72  struct hash< DGtal::SignedKhalimskyCell< dim, TInteger > >
73  {
75  {
76  auto const& p = pp.preCell();
77  return p.positive
78  ? boost::hash_range(p.coordinates.begin(), p.coordinates.end())
79  : boost::hash_range(p.coordinates.begin(), p.coordinates.end()) ^ ( (size_t) 0x7a0d3fe9 );
80  }
81  };
82 
83 }
84 
85 namespace boost{
91  template < DGtal::Dimension dim,
92  typename TInteger >
93  struct hash< DGtal::KhalimskyCell< dim, TInteger > >
94  {
96  {
97  auto const& p = pp.preCell();
98  return boost::hash_range(p.coordinates.begin(), p.coordinates.end());
99  }
100  };
101 
107  template < DGtal::Dimension dim,
108  typename TInteger >
109  struct hash< DGtal::SignedKhalimskyCell< dim, TInteger > >
110  {
112  {
113  auto const& p = pp.preCell();
114  return p.positive
115  ? boost::hash_range(p.coordinates.begin(), p.coordinates.end())
116  : boost::hash_range(p.coordinates.begin(), p.coordinates.end()) ^ ( (size_t) 0x7a0d3fe9 );
117  }
118  };
119 
120 }
121 
122 
123 
124 #endif // !defined KhalimskyCellHashFunctions_h
125 
126 #undef KhalimskyCellHashFunctions_RECURSES
127 #endif // else defined(KhalimskyCellHashFunctions_RECURSES)
size_t operator()(const DGtal::KhalimskyCell< dim, TInteger > &pp) const
Definition: Boost.dox:28
DGtal::uint32_t Dimension
Definition: Common.h:113
PreCell const & preCell() const
Returns the underlying constant pre-cell.
size_t operator()(const DGtal::KhalimskyCell< dim, TInteger > &pp) const
STL namespace.
size_t operator()(const DGtal::SignedKhalimskyCell< dim, TInteger > &pp) const
SPreCell const & preCell() const
Returns the underlying constant signed pre-cell.
size_t operator()(const DGtal::SignedKhalimskyCell< dim, TInteger > &pp) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value...
Represents an (unsigned) cell in a cellular grid space by its Khalimsky coordinates.