Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NodeIterator and Stream support #2051

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Added NodeIterator and Stream support #2051

merged 2 commits into from
Nov 15, 2023

Conversation

jhy
Copy link
Owner

@jhy jhy commented Nov 15, 2023

Improvement: added the NodeIterator class, to efficiently traverse a node tree using the Iterator interface.

And added Stream Element#stream() and Node#nodeStream() methods, to enable fluent composable stream pipelines of node traversals.

NodeIterator only hits nodes once (vs head and tail for NodeTraversor), is restartable, supports modifications of the node it just emitted (e.g. replace, remove), supports type filtering, and emits in document order.

Refactored most head-only uses of NodeTraversor to use the NodeIterator or a Stream backed by it.

Improvement: added the NodeIterator class, to efficiently traverse a node tree using the Iterator interface.

And added Stream Element#stream() and Node#nodeStream() methods, to enable fluent composable stream pipelines of node traversals.

NodeIterator only hits nodes once (vs head and tail for NodeTraversor), is restartable, supports modifications of the node it just emitted (e.g. replace, remove), supports type filtering, and emits in document order.

Refactored most head-only uses of NodeTraversor to use the NodeIterator or a Stream backed by it.
@jhy jhy added this to the 1.17.1 milestone Nov 15, 2023
@jhy jhy self-assigned this Nov 15, 2023
@jhy jhy merged commit f51115f into master Nov 15, 2023
12 checks passed
@jhy jhy deleted the stream-iterator branch November 15, 2023 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant