|
Post by EurasianVixen on Mar 17, 2002 12:35:28 GMT -5
I'm having great troubles with insert() method. I don't know how to traverse down the tree. For example, say: www.blah.com/~blerg/haha.html is the first address to be inserted into the tree. So there are 3 nodes in heirarchy in the tree. and say the second address to be inserted is: www.blah.com/~blerg/heheh.html so it first checks www.blah.com exists: it does. then ~blerg: it does exist. then heheh.html: it does NOT exist. and therefore, it must be inserted into ~blerg's vector, right? How do you do that? How do u keep track of which vector the current node should be inserted?
|
|
|
Post by 1.8T on Mar 17, 2002 15:11:45 GMT -5
i dunno if wut i'm gonna say is gonna help since i don't even know how to write teh URLTreeNode class., but here's my thoughts on it,.., insert should be a recursive method (or have a helper method that's recursive).,. and go through the conditions., until it reaches a point where " ~blerg doesn't exist".,. then it adds the link to the node of the vector to its parent...
again i dunno wut i'm saying..,,. just trying to help., sorry if i've confused u more.,.,.,
my question about insert() is, does it chop up the url into url-parts and make a node for each and make a "link" from each sucessive node? what i mean by link is something similar to A3..,
|
|
|
Post by Sky on Mar 17, 2002 20:51:15 GMT -5
yep...ur right...insert/remove/contains all have to chop the url into sub-parts and do some kind of tracing a path in the tree for each sub-part...when u found out at which point a sub-part does not exist...then perform the appropiate action ...u have to do that by recursion of course...
for E...V...'s question...if u know which sub-part does not exist in the tree...u should have a method in URLTreeNode to do insertion into the vector...then u just call this method to insert a new node to the vector of the last existing part node...i think i kinda say it in a very confusing way...sorry...
|
|