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

Method findIndexByKey

Engine/source/forest/forestCell.cpp:229–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229bool ForestCell::findIndexByKey( ForestItemKey key, U32 *outIndex ) const
230{
231 // Do a simple binary search.
232
233 U32 i = 0,
234 lo = 0,
235 hi = mItems.size();
236
237 const ForestItem *items = mItems.address();
238
239 while ( lo < hi )
240 {
241 i = (lo + hi) / 2;
242
243 if ( key < items[i].getKey() )
244 hi = i;
245 else if ( key > items[i].getKey() )
246 lo = i + 1;
247 else
248 {
249 *outIndex = i;
250 return true;
251 }
252 }
253
254 *outIndex = lo;
255 return false;
256}
257
258const ForestItem& ForestCell::insertItem( ForestItemKey key,
259 ForestItemData *data,

Callers 1

forestDataFile.cppFile · 0.80

Calls 2

sizeMethod · 0.45
addressMethod · 0.45

Tested by

no test coverage detected