Changeset 2162 for GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
- Timestamp:
- 02/23/07 18:37:15 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h
r2161 r2162 8 8 #include "PvsBase.h" 9 9 #include "google/dense_hash_set" 10 #include "google/dense_hash_map" 10 11 11 12 … … 24 25 }; 25 26 26 size_t operator()(T a) const27 /*int operator()(T a) const 27 28 { 29 if (!a) 30 return -2; 28 31 return (size_t)(a->GetId()); 32 }*/ 33 34 int operator()(int a) const 35 { 36 return a; 29 37 } 38 30 39 31 40 bool operator()(T a, T b) const … … 36 45 37 46 38 #define HASH_SET google::dense_hash_set<T, my_hash_compare<T> > 47 //#define HASH_SET google::dense_hash_set<T, my_hash_compare<T> > 48 #define HASH_SET google::dense_hash_map<int, T>//, hash_compare<int> > 39 49 //#define HASH_SET stdext::hash_set<T, my_hash_compare<T> > 40 50 #define HASH_ITERATOR HASH_SET::iterator … … 63 73 T Next(S &pdf) 64 74 { 65 T sample = *mItCurrent;75 T sample = (*mItCurrent).second; 66 76 ++ mItCurrent; 67 77 … … 71 81 T Next() 72 82 { 73 T sample = *mItCurrent;83 T sample = (*mItCurrent).second; 74 84 ++ mItCurrent; 75 85 … … 94 104 95 105 //HashPvs(): mEntries((Intersectable *)100) {}; 96 HashPvs() {}; 106 HashPvs() 107 { 108 mEntries.set_deleted_key(-1); 109 mEntries.set_empty_key(-2); 110 //mEntries.Reset(); 111 }; 97 112 //virtual ~HashPvs() {}; 98 113 … … 207 222 bool HashPvs<T, S>::Find(T sample, typename HASH_ITERATOR &it) 208 223 { 209 it = mEntries.find(sample );224 it = mEntries.find(sample->GetId()); 210 225 211 226 // already in map 212 227 return (it != mEntries.end()); 213 return false;214 228 } 215 229 … … 237 251 return 0.0f; 238 252 239 mEntries.insert( sample);253 mEntries.insert(pair<int, T>(sample->GetId(), sample)); 240 254 return 1.0f; 241 242 /*pair<HASH_SET::iterator, bool> p = mEntries.insert(sample);243 244 if (p.second)245 return 0.0f;246 else247 return 1.0f;*/248 255 } 249 256 … … 257 264 if (!Find(sample, it)) 258 265 { 259 mEntries.insert(sample); 260 } 261 262 //pair<HASH_SET::iterator, bool> p = mEntries.insert(sample); 266 mEntries.insert(pair<int, T>(sample->GetId(), sample)); 267 } 263 268 } 264 269 … … 268 273 const float pdf) 269 274 { 270 /*pair<HASH_ITERATOR, bool> p = mEntries.insert(sample); 275 static CONST_HASH_ITERATOR it; 276 277 it = mEntries.find(sample->GetId());//, sample); 271 278 272 279 // already in map 273 return p.second; 274 */ 275 static HASH_ITERATOR it; 280 const bool found = (it != mEntries.end()); 276 281 277 282 // already in map 278 if (Find(sample, it)) 283 if (found) 284 //if (Find(pair<int, T>(sample->GetId(), sample), it)) 279 285 return false; 280 281 mEntries.insert(sample); 286 287 mEntries.insert(pair<int, T>(sample->GetId(), sample)); 288 282 289 return true; 283 290 } … … 375 382 for (ait = a.mEntries.begin(); ait != ait_end; ++ ait) 376 383 { 377 mergedPvs.AddSample( *ait, 1.0f);384 mergedPvs.AddSample((*ait).second, 1.0f); 378 385 } 379 386 … … 382 389 for (bit = b.mEntries.begin(); bit != bit_end; ++ bit) 383 390 { 384 mergedPvs.AddSample(*bit, 1.0f); 385 } 386 391 mergedPvs.AddSample((*bit).second, 1.0f); 392 } 387 393 } 388 394
Note: See TracChangeset
for help on using the changeset viewer.