MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / reOrder

Method reOrder

Engine/source/console/simSet.cpp:278–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276//-----------------------------------------------------------------------------
277
278bool SimSet::reOrder( SimObject *obj, SimObject *target )
279{
280 MutexHandle handle;
281 handle.lock(mMutex);
282
283 iterator itrS, itrD;
284 if ( (itrS = find(begin(),end(),obj)) == end() )
285 {
286 // object must be in list
287 return false;
288 }
289
290 if ( obj == target )
291 {
292 // don't reorder same object but don't indicate error
293 return true;
294 }
295
296 if ( !target )
297 {
298 // if no target, then put to back of list
299
300 // don't move if already last object
301 if ( itrS != (end()-1) )
302 {
303 // remove object from its current location and push to back of list
304 mObjectList.erase(itrS);
305 mObjectList.push_back(obj);
306 }
307 }
308 else
309 {
310 // if target, insert object in front of target
311 if ( (itrD = find(begin(),end(),target)) == end() )
312 // target must be in list
313 return false;
314
315 mObjectList.erase(itrS);
316
317 // once itrS has been erased, itrD won't be pointing at the
318 // same place anymore - re-find...
319 itrD = find(begin(),end(),target);
320 mObjectList.insert(itrD, obj);
321 }
322
323 return true;
324}
325
326//-----------------------------------------------------------------------------
327

Callers 1

simSet.cppFile · 0.45

Calls 7

beginFunction · 0.85
endFunction · 0.85
findFunction · 0.50
lockMethod · 0.45
eraseMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected