----------------------------------------------------------------------------- VTreeNode::getIndex(); Returns the index of the object in relation to the sibling nodes. -----------------------------------------------------------------------------
| 243 | // |
| 244 | //----------------------------------------------------------------------------- |
| 245 | int VTreeNode::getIndex( void ) |
| 246 | { |
| 247 | if ( !inTree() ) |
| 248 | { |
| 249 | // No Index. |
| 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | ITreeNode *walk = NULL; |
| 254 | if ( mParentNode ) |
| 255 | { |
| 256 | walk = mParentNode->mChildNode; |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | walk = this; |
| 261 | while ( walk->mSiblingPrevNode ) |
| 262 | { |
| 263 | // Walk Up. |
| 264 | walk = walk->mSiblingPrevNode; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | for ( int i = 0; walk; walk = walk->mSiblingNextNode, i++ ) |
| 269 | { |
| 270 | if ( walk == this ) |
| 271 | { |
| 272 | return i; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | AssertFatal( false, "VTreeNode::getIndex() - Node List Broken?" ); |
| 277 | |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | //----------------------------------------------------------------------------- |
| 282 | // |