PDA

View Full Version : C++ Finding next and previous sibling


DesertRose
November 5th, 2007, 03:08 PM
Hi and bye. there's no question anymore. ;)

Wybiral
November 5th, 2007, 03:13 PM
What data structure are you asking about? An STL container?

aks44
November 5th, 2007, 03:17 PM
With so few indications it's hard to help. What do you want exactly? Some code (even if it is an incorrect "prototype") would definitely help...


As far as I can tell from the little information you gave, my best guess (provided you use a sanely designed library) would be something like:
Node* nextParentSibling = node->parent()->nextSibling();
Node* previousParentSibling = node->parent()->previousSibling();
// do whatever you want with those nodes

(yeah, that second paragraph is totally random :-\")

DesertRose
November 5th, 2007, 04:14 PM
;) cheers

Wybiral
November 5th, 2007, 04:44 PM
So it's a standard binary tree where each node looks like:


struct
{
void *data;
node* left, right;
} node;


Right? Or does it store its parent node? Or does it store any information on the levels? You need to give us more info, maybe some code. Not all binary trees are implemented the same.

DesertRose
November 6th, 2007, 03:31 AM
;) cheers