Closed GoogleCodeExporter closed 9 years ago
Unfortunately, it can't be made O(1) with the existing data structures.
Also, providing the num_children functionality without the indexing
functionality makes it very asymmetrical; having them together, however,
encourages people to iterate through nodes in a inefficient way.
I'll think about it further and update the issue once I reach a decision.
Original comment by arseny.k...@gmail.com
on 22 Jul 2011 at 5:24
When I first posted this I hadn't really discovered your xpath stuff yet. In
the places were I wanted to perform an iteration operation I simply do an xpath
query. And in general when I do any xml to binary conversions I plan on
iterating over the query results. Another thing to note is that those query
results allow you to ask about the size() or number of items found by the query
which is exactly what I needed. Certainly having a O(1) operation for
num_children would be nice, but the xpath interface actually provides
everything I needed, it just took me a while to discover it. Perhaps a small
blurb/example in the documentation about figuring out how many children a given
node has would be worth something.
Original comment by VirtualT...@gmail.com
on 22 Jul 2011 at 12:16
I'll mention this in documentation once this question comes up again; for now
there does not seem to be a natural place where to put it (especially since
there are different ways to do it - with STL algorithms & node iterators the
easiest one is probably std::distance(node.begin(), node.end()))
Original comment by arseny.k...@gmail.com
on 8 Mar 2012 at 7:02
Original issue reported on code.google.com by
VirtualT...@gmail.com
on 18 May 2011 at 9:17