I'm trying to figure out how I can iterate in reverse, and forward through this, or atleast call a method in reverse.
Here is how it works.
Widgets have a std::vector of Widget* which are that control's children. The child vector is z ordered which means that child[0] is behind child[1] (in render order). Each control has a pointer to its parent except for the root (dummy) widget whos parent is NULL.
For my rendering, I need to sort of do a staircase sort of iteration (back to front) ex:
root->child[0];
root->child[0]->child[0];
root->child[0]->child[1];
root->child[1];
root->child[1]->child[0];
root->child[1]->child[1];
However to find which widget is under the mouse, I must do my point in rectangle test from front to back:
root->child[9]->child[1];
root->child[9]->child[0];
root->child[9];
root->child[8]->child[2];
root->child[8]->child[1];
root->child[8]->child[0];
root->child[8];
What sort of iteration would I need to efficiently do the above 2 types of iterations? (back to front, front to back).
Thanks