|
Rational Rose.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Rational Rose is freeware? Wow, since when? I got to get me some of that.
led mike
|
|
|
|
|
led mike wrote: Wow, since when?
When I'm at work.
lol, I just read the title and replied.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I have a tree data structure that I use for my scene graph that I traverse each frame to update 20.000 nodes, I am currently doing the typical recursive traversal but probably it would be quicker if I converted the recursive traversal in an iterative one, does anyone have any hint on how to do that?
Here is how my data structure looks like:
class Node
{
public:
... some data ...
std::vector<node*> Children;
};
void do_something_before(Node*)
{
...
}
void do_something_after(Node*)
{
...
}
void traverse(Node* node)
{
do_something_before(node);
for(int i=0; i<node->Children.size(); ++i )
traverse(node->Children[i]);
do_something_after(node);
}</node-></node*>
Thanks
|
|
|
|
|
Michele Bosi wrote: does anyone have any hint on how to do that?
You can use a stack to simulate calling a function recursively. For instance, look here[^]
|
|
|
|
|
I already saw that example of wikipedia, unfortunately it is for a binary tree meanwhile I would need a more general N-ary tree and with operations on the node performed before and after visiting the children. I thought there would be a "text-book" solution to this but it seems that this is a much more complex problem than I expected...
|
|
|
|
|
Michele Bosi wrote: I thought there would be a "text-book" solution to this but it seems that this is a much more complex problem than I expected...
It is not trivial, but it is still pretty straightforward: replace recursive calls with a loop and a stack. Local variables would take values from the stack, much like function parameters, and recursive function calls would translate to putting parameters on the stack and going to the beginning of the loop.
|
|
|
|
|
In theory I would also do as you say, but when you actually try to translate it into practice everything becomes much more foggy, especially the management of the 2 functions "do_something_before()" and "do_soemthing_after()".
|
|
|
|
|
Thanks to all the replies, it turned out that a easier way of optimizing such code is to make the data structures as cache friendly as possible making the nodes smaller and careful allocation, so one can forget about iterative traversal for another bit...
|
|
|
|
|
Expecting your wonderfull answer.
I am expecting your wonderfull answer!
|
|
|
|
|
Coding?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Of course!
I am expecting your wonderfull answer!
|
|
|
|
|
You can create almost any game using DirectX easily
If you know, give the link for that game to refer..
Refer this: Creating a Game Using DirectX (C++)[^]
--
"Programming is an art that fights back!"
|
|
|
|
|
rp_suman wrote: You can create almost any game using DirectX easily
You're a rather optimistic guy.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
You may be true!!
I believe, using MS products, we can do whatever they've created it for..
--
"Programming is an art that fights back!"
|
|
|
|
|
Unfortunately we should also take into account human skills...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
of course
You are right Pallini!!
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
There is no spoon globule.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
I didn't get it (maybe my poor English ). Could you elaborate, please?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
it was a reference to the movie "Matrix" : "There's no spoon"
|
|
|
|
|
What's a Matrix?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
"The Matrix is everywhere, it is all around us, even now in this very room. You can see it when you look out your window, or you turn on your television. You can feel it when you go to work, when you go to church, when you pay your taxes. It is the world that has been pulled over your eyes to blind you from the truth."
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Oh, thank you, I forgot completely about the spoon (I'm getting older, my friend... ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Matrix film. Scene on the elevator's roof. Neo look at the top of the elevator having an "idea" of what was coming and says: "there is no spoon".
Difficult to understand if you didn't see the film
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|