开发者

Is it possible to search jdom for attributes?

Is it possible in jdom to get the children of a node that share a certain attribute without having to look at all children in bruteforce? Is search in l开发者_运维技巧ogarithmic time possible?


Is search in logarithmic time possible?

No, because that would require some sort of index keyed on that particular attribute, and why would JDOM keep such an index?

You could have an XPath implementation that builds such an index internally to speed up repeated searches, but it would still have to build it first.


If you wanted to create an index on the specific attribute, you could use SAX and create an index as you parse the document. This could give you O(1) to find the attribute, after you constructed the index.

In JDOM, a logrithmic search would be impossible because, in divide and conquer searches an ordering of the nodes is assumed (like in a binary search tree). Since the Elements of a JDOM Document have no ordering, there is no way to shrink the search space.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜