Changeset 3297
- Timestamp:
- 11/06/09 13:58:45 (2 weeks ago)
- Location:
- MOAB/trunk
- Files:
-
- 3 modified
-
MBCore.cpp (modified) (2 diffs)
-
MBRange.cpp (modified) (3 diffs)
-
MBRange.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
MOAB/trunk/MBCore.cpp
r3273 r3297 1217 1217 MBRange temp_range; 1218 1218 std::vector<MBEntityHandle> temp_vec; 1219 std::vector<MBEntityHandle>::const_iterator adj_it; 1219 1220 MBErrorCode result = MB_SUCCESS, tmp_result; 1220 1221 … … 1235 1236 if (MB_SUCCESS != tmp_result) result = tmp_result; 1236 1237 1238 std::sort( temp_vec.begin(), temp_vec.end() ); 1239 1237 1240 // if we're on the first iteration and we didn't come in with entities, 1238 1241 // just get the first results and move on 1239 1242 if (adj_entities.empty() && from_it == from_entities.begin()) { 1240 std::copy(temp_vec. begin(), temp_vec.end(), mb_range_inserter(adj_entities));1243 std::copy(temp_vec.rbegin(), temp_vec.rend(), mb_range_inserter(adj_entities)); 1241 1244 continue; 1242 1245 } 1243 1246 1244 1247 // operate on the vectors 1248 MBRange::iterator hint = adj_entities.begin(); 1245 1249 if (operation_type == MBInterface::INTERSECT) { 1246 // only have to sort if we're doing intersection 1247 std::sort(temp_vec.begin(), temp_vec.end()); 1248 std::set_intersection(adj_entities.begin(), adj_entities.end(), 1249 temp_vec.begin(), temp_vec.end(), 1250 mb_range_inserter(temp_range)); 1251 adj_entities.swap(temp_range); 1250 adj_it = temp_vec.begin(); 1251 while (hint != adj_entities.end()) { 1252 while (adj_it != temp_vec.end() && *adj_it < *hint) 1253 ++adj_it; 1254 if (adj_it == temp_vec.end()) { 1255 adj_entities.erase( hint, adj_entities.end() ); 1256 break; 1257 } 1258 1259 if (*adj_it == *hint) 1260 ++hint; 1261 else 1262 hint = adj_entities.erase(hint); 1263 } 1264 1265 // If doing INTERSECT and the current results are the empty set, 1266 // then the final result must also be the empty set. 1267 if (adj_entities.empty()) 1268 return MB_SUCCESS; 1252 1269 } 1253 1270 else if (operation_type == MBInterface::UNION) { 1254 std::copy(temp_vec.begin(), temp_vec.end(), mb_range_inserter(adj_entities)); 1271 for (adj_it = temp_vec.begin(); adj_it != temp_vec.end(); ++adj_it) 1272 hint = adj_entities.insert( hint, *adj_it ); 1255 1273 } 1256 1274 } -
MOAB/trunk/MBRange.cpp
r3129 r3297 232 232 */ 233 233 234 MBRange::iterator MBRange::insert( MBEntityHandle val)234 MBRange::iterator MBRange::insert( MBRange::iterator hint, MBEntityHandle val ) 235 235 { 236 236 … … 247 247 // find the location in the list where we can safely insert 248 248 // new items and keep it ordered 249 PairNode* jter = mHead.mNext; 249 PairNode* hter = hint.mNode; 250 PairNode* jter = hter->first <= val ? hter : mHead.mNext; 250 251 for( ; (jter != &mHead) && (jter->second < val); jter=jter->mNext); 251 252 PairNode* iter = jter; … … 300 301 } 301 302 302 303 /*!304 inserts a range of values305 */306 MBRange::iterator MBRange::insert(MBEntityHandle val1, MBEntityHandle val2)307 {308 309 if(val1 == 0 || val1 > val2)310 return end();311 312 return insert( begin(), val1, val2 );313 }314 315 303 MBRange::iterator MBRange::insert( MBRange::iterator prev, 316 304 MBEntityHandle val1, 317 305 MBEntityHandle val2 ) 318 306 { 319 assert( val1 <= val2 && val1 ); 307 if(val1 == 0 || val1 > val2) 308 return end(); 320 309 321 310 // Empty -
MOAB/trunk/MBRange.hpp
r3110 r3297 242 242 inline bool empty() const; 243 243 244 iterator insert( iterator hint, MBEntityHandle val ); 245 244 246 //! insert an item into the list and return the iterator for the inserted item 245 iterator insert(MBEntityHandle val); 247 iterator insert(MBEntityHandle val) 248 { return insert( begin(), val ); } 246 249 247 250 //! insert a range of items into this list and return the iterator for the first 248 251 //! inserted item 249 iterator insert(MBEntityHandle val1, MBEntityHandle val2); 252 iterator insert( iterator hint, MBEntityHandle first, MBEntityHandle last ); 253 254 //! insert a range of items into this list and return the iterator for the first 255 //! inserted item 256 iterator insert(MBEntityHandle val1, MBEntityHandle val2) 257 { return insert( begin(), val1, val2 ); } 250 258 251 259 //! remove an item from this list and return an iterator to the next item … … 339 347 340 348 int index(MBEntityHandle handle) const; 341 342 MBRange::iterator insert( MBRange::iterator prev,343 MBEntityHandle first,344 MBEntityHandle last );345 349 346 350 protected:
![(please configure the [header_logo] section in trac.ini)](/projects/ITAPS/chrome/common/trac_banner.png)