Home » Community » Forums » » Trees Part 1
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Trees Part 1
Post Reply 
This is my first attempt at an in-depth article, so go easy on me

I would appreciate comments though. Thanks

===============================================
But as for me, hungry oblivion
Devour me quick, accept my orison
My earnest prayers Which do importune thee,
With gloomy shade of thy still empery,
To vail both me and my poesy

 User Rating: 1344   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

Thanks a lot .. good tutorial

Hope the next part coming soon .. :-)

--
Deckhead

 User Rating: 1015    Report this Post to a Moderator | Link

Hey I also say it is a great tutorial hope to see the next tut soon

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Even though STL now provides most usual data structures, it is sometimes useful to implement your own.
However, I think that the interfaces should still be STL compatible (mainly iterators), so that we don't relapse into the dark old days, when code wasn't really reusable.

Photon

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

HERE'S A tup (damed capslock)...

next time, put the class implementation in the article with a description as well. It'll make understand the source so much easier (for newbies).

Also, someone else commented on using iterators more... while I havn't looked at the source yet, my tree implementation uses iterators for finding the next child node (the children are stored in a vector).

The end interface doesn't really need access to the iterator, or any other internal crap.

If you extent the class using inheritence, then yes, knowledge and access to the internals is helpful, but that is a little to ocmplex for a basic tutoiral.

After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming

 User Rating: 1106   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Nice explanation. If this is covered by the STL then the C++ should be compatible. I'm looking for a general solution for a set of C functions.


 User Rating: 1015    Report this Post to a Moderator | Link

BTW, for the power function on the first page, it's better to check if power is 0 and return 1. Cause then anything to power 0 also works correctly... And another case for id (power < 0) return 1/getpower (N, -power)

POOP!!!!

--------------------------

- Alexey. (IGD = Independent Game Developer)

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

quote:
Original post by arexey

BTW, for the power function on the first page, it's better to check if power is 0 and return 1. Cause then anything to power 0 also works correctly... And another case for id (power < 0) return 1/getpower (N, -power)



yeah, i thought i'd make a little optimisation though.

I suppose i did it without thinking, heh. I'll try to remember to explain all the little shortcuts I make from now on.

 User Rating: 1344   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

There's something I don't understand in this article, though. I mean, the Introduction of the Trees Series, where the author coded 2 types of iterators : The Recursive one and the While loop. I can easily understand the 2nd, but regarding the Recursive one....... :

int getPower( int number, int power )
{
if( power != 1 )
return number * getPower( number, power - 1 );
else
return number;
}

As you can see, getPower(...) is a function, and we folks always code the operation and behaviour of a function inside it, and now it's a FUNCTION being called within a FUNCTION!!!!! This is weird! >:-D

Now pals.....please listen to my explaination of the code and correct me if I'm wrong.

1) Firstly, the name of this function is called getPower(...) of type int. Right? >:-D

2) Now, the first line in the function means that if the "power" parameter isn't equivalent to 1, then the value of the "number" parameter multiply by the getPower(.....) is returned. Each time getPower(...) gets called within the function itself, it'll just subtract 1 from the "power" parameter and gets called again, and then it subtracts 1 from the "power" parameter and gets called again and so on......and till the "power" parameter is 1, then simply, the "number" parameter is returned.

Am I right? If I'm anywhere wrong, do correct me, cos' I need to learn such essential algorithms for mastering game programming. >:-D

Since it''s cool to have our own signatures in every posts in GameDev.net, allow me to join in the fun. More is merrier, right? Now let''s see....what shall my signature be? Ah-ha! Got it!!!!!
"Now pal...I wouldn''t do dat'' if I were you, or this young lady might get hurt!"

Heh-heh-heh! Cool eh? Now, dat''s Cowboy''s speech! Hee-haw!!!!! :-D

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Actually, it's a great tutorial, however, I can't find the member function child() in your class. Another thing is as your sample of depth-traversal currentChild is a member function of your pre-defined class, not a member variable. =)

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: