Changeset 2161 for GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
- Timestamp:
- 02/23/07 13:54:56 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
r2146 r2161 2 2 #define __HASHPVS_H 3 3 4 //#include <hash_map> 4 5 5 #include <hash_set> 6 6 #include "common.h" 7 7 #include <math.h> 8 8 #include "PvsBase.h" 9 #include "google/dense_hash_set" 9 10 10 11 … … 25 26 size_t operator()(T a) const 26 27 { 27 size_t h = (size_t)(a->GetId());// % 2000; 28 //for (; *s; ++s) 29 // h = 5 * h + *s; 30 return h; 28 return (size_t)(a->GetId()); 31 29 } 32 30 … … 37 35 }; 38 36 39 /* 40 template<typename T> 41 struct gt 42 { 43 bool operator() (T s1, T s2) const 44 { 45 return s1 > s2; 46 } 47 }; 48 */ 49 //#define HASH_SET stdext::hash_set<T, stdext::hash_compare<T, gt<T> > > 50 #define HASH_SET stdext::hash_set<T, my_hash_compare<T> > 37 38 #define HASH_SET google::dense_hash_set<T, my_hash_compare<T> > 39 //#define HASH_SET stdext::hash_set<T, my_hash_compare<T> > 40 #define HASH_ITERATOR HASH_SET::iterator 41 #define CONST_HASH_ITERATOR HASH_SET::const_iterator 51 42 52 43 /** Iterator over a hash pvs. … … 59 50 HashPvsIterator<T, S>() {} 60 51 61 HashPvsIterator<T, S>(const typename HASH_SET::const_iterator&itCurrent,62 const typename HASH_SET::const_iterator&itEnd):52 HashPvsIterator<T, S>(const typename CONST_HASH_ITERATOR &itCurrent, 53 const typename CONST_HASH_ITERATOR &itEnd): 63 54 mItCurrent(itCurrent), mItEnd(itEnd) 64 55 { … … 72 63 T Next(S &pdf) 73 64 { 74 // hack: create new pvs entry 75 return *(mItCurrent) ++; 65 T sample = *mItCurrent; 66 ++ mItCurrent; 67 68 return sample; 76 69 } 77 70 78 71 T Next() 79 72 { 80 // hack: create new pvs entry 81 return *(mItCurrent) ++; 73 T sample = *mItCurrent; 74 ++ mItCurrent; 75 76 return sample; 82 77 } 83 78 84 79 private: 85 typename HASH_SET::const_iteratormItCurrent;86 typename HASH_SET::const_iteratormItEnd;80 typename CONST_HASH_ITERATOR mItCurrent; 81 typename CONST_HASH_ITERATOR mItEnd; 87 82 }; 88 83 … … 139 134 it would be added in the sorted vector. 140 135 */ 141 bool Find(T sample, typename HASH_SET::iterator&it);136 inline bool Find(T sample, typename HASH_ITERATOR &it); 142 137 143 138 typename HashPvsIterator<T, S> GetIterator() const; … … 210 205 211 206 template <typename T, typename S> 212 bool HashPvs<T, S>::Find(T sample, typename HASH_ SET::iterator&it)207 bool HashPvs<T, S>::Find(T sample, typename HASH_ITERATOR &it) 213 208 { 214 209 it = mEntries.find(sample); … … 216 211 // already in map 217 212 return (it != mEntries.end()); 213 return false; 218 214 } 219 215 … … 236 232 float HashPvs<T, S>::AddSample(T sample, const float pdf) 237 233 { 238 static HASH_ SET::iteratorit;234 static HASH_ITERATOR it; 239 235 240 236 if (Find(sample, it)) … … 256 252 void HashPvs<T, S>::AddSampleDirty(T sample, const float pdf) 257 253 { 258 static HASH_ SET::iteratorit;254 static HASH_ITERATOR it; 259 255 260 256 // not yet in map … … 272 268 const float pdf) 273 269 { 274 /*pair<HASH_ SET::iterator, bool> p = mEntries.insert(sample);270 /*pair<HASH_ITERATOR, bool> p = mEntries.insert(sample); 275 271 276 272 // already in map 277 273 return p.second; 278 274 */ 279 static HASH_ SET::iteratorit;275 static HASH_ITERATOR it; 280 276 281 277 // already in map … … 375 371 const HashPvs<T, S> &b) 376 372 { 377 HASH_SET::const_iteratorait, ait_end = a.mEntries.end();373 CONST_HASH_ITERATOR ait, ait_end = a.mEntries.end(); 378 374 379 375 for (ait = a.mEntries.begin(); ait != ait_end; ++ ait) … … 382 378 } 383 379 384 HASH_SET::const_iteratorbit, bit_end = b.mEntries.end();380 CONST_HASH_ITERATOR bit, bit_end = b.mEntries.end(); 385 381 386 382 for (bit = b.mEntries.begin(); bit != bit_end; ++ bit) … … 389 385 } 390 386 391 //cerr << "not implemented" << endl;392 387 } 393 388
Note: See TracChangeset
for help on using the changeset viewer.