Skip to content

Reverse iteration feature #33

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

Merged
merged 6 commits into from
Dec 2, 2024
Merged

Reverse iteration feature #33

merged 6 commits into from
Dec 2, 2024

Conversation

plar
Copy link
Owner

@plar plar commented Nov 20, 2024

This PR introduces several enhancements and refactors to improve the tree traversal capabilities within the codebase, adding the ability to traverse in reverse order, refining API methods, and restructuring tests for better coverage and readability. Below are the main changes included in this PR:

Key Changes

Traversal Enhancements

  • Added a new traversal option, tree.TraverseReverse, allowing iterations over nodes in reverse order.
  • Modified the tree.ForEach and tree.ForEachPrefix methods to support optional traversal parameters.

Iterator Refactoring

  • Introduced newTraverseFunc to replace traverseContext, which simplifies the traversal logic by using function types (traverseFunc) instead of struct-based contexts.
  • Enhanced the iterator logic to support reverse traversals.

Test Suite Expansion

  • Added tests for prefix-based traversal operations in both directions.
  • Created new tests to verify the reverse traversal implementation for tree.ForEach, tree.ForEachPrefix, and tree.Iterator.

Overall Benefits

Performance

The introduction of reverse traversal provides a flexible and efficient means of traversing large datasets, reducing overhead in scenarios where reverse-order processing is needed.

plar added 3 commits November 19, 2024 23:09
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
@plar plar self-assigned this Nov 20, 2024
@plar plar added the feature label Nov 20, 2024
plar added 3 commits November 20, 2024 03:24
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
@plar plar merged commit f8966a6 into master Dec 2, 2024
6 checks passed
@plar plar deleted the reverse-iteration branch December 13, 2024 20:52
plar added a commit that referenced this pull request Dec 16, 2024
* introduce TraverseReverse option for Tree API functions
* add reverse implementation
* update README.md
* update Tree interface docs
* fix names, test asserts, node4 clearLastElement func
* cleanup: remove unused code;

---
Signed-off-by: Pavel Larkin <laxkin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant