|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Trees Part 1 |
|
![]() Mithrandir Member since: 9/14/1999 |
||||
|
|
||||
| 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 |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Thanks a lot .. good tutorial Hope the next part coming soon .. :-) -- Deckhead |
||||
|
||||
![]() Katanaa Member since: 3/18/2001 From: Belgium |
||||
|
|
||||
| Hey I also say it is a great tutorial |
||||
|
||||
![]() Photon Member since: 1/9/2000 |
||||
|
|
||||
| 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 |
||||
|
||||
![]() Nurgle GDNet+ Member since: 7/31/1999 From: Bath, United Kingdom |
||||
|
|
||||
| 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 |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| 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. |
||||
|
||||
![]() arexey Member since: 6/7/2001 From: USA |
||||
|
|
||||
| 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) |
||||
|
||||
![]() Mithrandir Member since: 9/14/1999 |
||||
|
|
||||
quote: 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. |
||||
|
||||
![]() Xeon_Boy Member since: 7/3/2001 From: Singapore |
||||
|
|
||||
| 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 |
||||
|
||||
![]() tarkey Member since: 7/1/2003 |
||||
|
|
||||
| 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. =) |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|