Apart from recursively querying each node, are there any other options for searching for a node given some identifier?
Apart from recursively querying each node, are there any other options for searching for
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, recursion is the most natural thing if you’re using a tree. Other than that, you could maintain a list or a collection outside of the tree, which seems superfluous, or you could simply linearly iterate over the list of tree nodes, which is probably going to be slower, but at least removes any traversal-specific code from the nodes, if that’s of any value.
I can’t see how any kind of specific tree query (e.g. xpath) that’s looking for all nodes of the form a.b.c could be doing anything other than just traversing at level a for b’s, and traversing the b’s for c’s, in other words, some sort of filtered recursive tree traversal.