src/biu/LatticeNeighborhood.hh
Go to the documentation of this file.00001 #ifndef LATTICE_NEIGHBORHOOD_HH_ 00002 #define LATTICE_NEIGHBORHOOD_HH_ 00003 00004 00005 #include "NeighborVector.hh" 00006 00007 #include "biu/HashMap.hh" 00008 00009 namespace biu 00010 { 00016 class LatticeNeighborhood 00017 { 00018 protected: 00019 00020 #ifdef HAVE_GNU_HASH_MAP 00021 00027 struct hash_IntPoint { 00028 size_t operator()(const IntPoint& p) const 00029 { 00030 size_t hash = 5381; 00031 00032 hash = ((hash << 5) + hash) + (size_t)p.getX(); // hash * 33 + coordinate X 00033 hash = ((hash << 5) + hash) + (size_t)p.getY(); // hash * 33 + coordinate Y 00034 hash = ((hash << 5) + hash) + (size_t)p.getZ(); // hash * 33 + coordinate Z 00035 00036 return hash; 00037 } 00038 00039 }; 00040 00041 typedef __gnu_cxx::hash_map< IntPoint, const NeighborVector*, hash_IntPoint > P2N_MAP; 00042 #else 00043 typedef std::map< IntPoint, const NeighborVector* > P2N_MAP; 00044 #endif 00045 00046 protected: 00047 00048 const MoveAlphabet* moveAlph; 00049 NeighSet neighSet; 00050 00052 std::vector<const NeighborVector*> neighVec; 00053 00055 P2N_MAP vec2neigh; 00056 00057 public: 00058 LatticeNeighborhood( const MoveAlphabet* moveAlph_, 00059 const NeighSet& neighbors); 00060 00061 LatticeNeighborhood( const LatticeNeighborhood& nh ); 00062 00063 virtual ~LatticeNeighborhood(); 00064 00066 virtual 00067 unsigned int size() const; 00068 00073 virtual 00074 bool isElement( const IntPoint& vector) const; 00075 00081 virtual 00082 const NeighborVector& getElementByIndex(unsigned int index) const; 00083 00087 virtual 00088 const NeighborVector& getElement(const IntPoint& vector) const; 00089 00094 virtual 00095 const NeighborVector& getElement(const Move& move) const; 00096 00098 typedef NeighSet::const_iterator const_iterator; 00099 00102 virtual 00103 const_iterator begin() const; 00104 00107 virtual 00108 const_iterator end() const; 00109 }; 00110 00111 } // namespace biu 00112 00113 #include "LatticeNeighborhood.icc" 00114 00115 #endif /*LATTICE_NEIGHBORHOOD_HH_*/