OK thats not a back pack. You carry it like a briefcase or use the shoulder strap. *You* try strapping an ATX case with power supply and hard drives to your back. hahaha. (OK, that was really la...
Oh, dean, give me your best guess as to how I wrote the comment threading algorithm on here to work.
I could do it another way if I do incremental "Selects" to the database, instead of my one "Select * from comment" at the very beginning.
Do you query the database multiple times during the algorithm, or just once at the beginning like I did?
If I had multiple queries, I could forget about hashtables and Node Objects I think. This is how I'd do it that way:
have a function called printComments(int p_id), and call printComments(-1) in your page creation code.
STEP 1) Recordset recs = EXECUTE("Select * from comment where parent_id="+p_id);
STEP 2) For each record in recs:
STEP 2a)Print rec info (comment, date, etc.)
STEP 2b)call printComments(thisrec.comment_id) //pass this record's comment number as the parent_id
STEP 3)If no records, then this comment has no children (actually no comments in the database have this comment as its parent) so just return.
Basically, the difference between my two ideas is database retrieval time verses computation time. One is database-intensive, and the other is computationally-intensive.
You got it, dean. I went the database-intensive route. I'm not exactly sure which is the best way, but for now, it was the easiest way for me to accomplish the task in ColdFusion, which is not object oriented. The recursive call also keeps track of how many times it has been called for a comment, and this is how I output the indent level.
Guys...i know ian is definitely a certified genius, and dean...well, he's proving himself to me as well. But all this java junk doesn't get you nowhere. to be really smart, you have to know calculus and be able to apply it to computer programming, by intergrating the recursive variable functions into to the nodes within the class, then differentiate the entire function into terms of f'(x), thereby being able to graph your results...if you continue to differentiate, you will eventually find that f''(x) gives you your points of inflection, where you can apply the rest of the nodes of the class...whoopdeedooo i don't even know what i'm talking about!
actually the really funny thing is, I have done this. I took a class called Numerical Methods of Computation in College, cause I was a minoring in Applied Mathematics. And we had to write all these programs in C that would produce tables of figures for differential equations (which is like calculus on acid) using different aproximation algorithms. Anyway.
Actually, I wonder if the funny thing is that you had to do it for a class... and I did it for fun. Heh...
ian, you can take all my classes for fun if you want, and I'll take care of ezabel for a while...nobody will be the wiser.
Matt, you'd give up the opportunity to further your C++ knowledge?.......I'm ashamed to know you. :)
ohhh i most definitely would!