| 227 | } |
| 228 | |
| 229 | bool 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 | |
| 258 | const ForestItem& ForestCell::insertItem( ForestItemKey key, |
| 259 | ForestItemData *data, |
no test coverage detected