Releases: orxfun/orx-tree
Copy, Send and Sync for NodePtr and NodeIdx
Changes
This version Implements Copy for NodePtr.
Implements Send and Sync for NodeIdx.
Carries out a major refactoring for pointers and indices passed as values rather than references.
Finally, missing methods leaves_mut, leaves_mut_with, into_leaves and into_leaves_with methods are added for NodeMut.
Breaking Changes
This version introduces breaking changes due to the Copy implementation of the node pointer and node index. As recommended, their methods now take self rather than &self. Further, Tree methods that takes a node pointer or index as an argument now accept values by copy semantics rather than as references as in the prior version. Although this makes it more convenient to work with indices, it leads to compilation errors in the old code.
For instance, the following code block will not compile in the new version:
use orx_tree::*;
let mut tree = DynTree::new(1i32);
let mut root = tree.root_mut();
let [id2, id3] = root.push_children([2, 3]);
let node2 = tree.node(&id2); // errprIt needs to be fixed as below:
let node2 = tree.node(id2);Thanks to @hasezoey for suggestions and reviews.
NodeIdx Hash & Copy
Changes
- MSRV is added to readme, and CI jobs run on both stable and MSRV.
- CI enabled on all branches.
- Clippy suggestions enabled for tests, fixes are made wrt suggestions.
NodeIdximplementsHash.NodeIdxalways implementsCopyregardless of whether the variant implementsCopyor not.- parallel feature is explicitly listed. The older feature name orx-parallel is kept until next major version.
Thanks to @hasezoey for all these improvements.
Upgrade pinned vector dependencies 3.21
Upgrades PinnedVec for improved safety guarantees: https://github.com/orxfun/orx-pinned-vec/releases/tag/3.21.0
Also upgrades orx-parallel dependency.
Upgrade pinned vector dependencies
Merge pull request #164 from orxfun/new-pinned-vector-versions upgrade to new pinned vec and con iter versions
Parallel Walks
Parallelized Walks
- The main contribution of this release is enabling parallel iterators over various tree iterators and walks with any of the traversals. Parallelization is obtained simply by adding _par suffix to name of the sequential counterpart. These methods return a
orx_parallel::ParIterwhich allows for significant improvements in computation time. The following is the list of new methods returning parallel iterators:children_parancestors_parcustom_walk_parwalk_parwalk_with_parpaths_parpaths_with_parleaves_parleaves_with_par
Custom Walks
custom_walk(next_node)method is implemented. This method returns an iterator over the nodes with custom traversal strategy. Traversal strategy is determined by the argumentnext_node.next_nodeis a function with the signatureFn(Node) -> Option<Node>. Iteration starts with theselfand terminates whennext_nodereturnsNone. This provides a convenient and flexible way to create custom walks. Notice that iteration in all directions can be defined and infinite iterations can be created. Mutable versioncustom_walk_mut(next_node)is also implemented forNodeMut.
Allocation-Free Paths Iterator
pathswas returningimpl Iterator<Item = impl Iterator<&V::Item>>. Now it returnsimpl Iterator<Item = impl Iterator<&V::Item> + Clone>. In other words, eachpathelement is a cheaply cloneable iterator. This allows for converting the pathinto_iterablewhich can be iterated over multiple times, and hence, provides the means to avoid allocation and collecting the paths into collections.- Examples for different iterators, walks are added and linked from the documentation.
Parallelization
This release provides the initial support for parallelization over trees:
- Introduces
parandinto_parmethods on theTree. These methods create parallel iterators over all nodes of the tree in arbitrary order. In other words, they are the parallel counterpart of theiterandinto_itermethods of the tree. - These implementations use direct parallelization over the underlying pinned vector, and hence, result in efficient gains in computation time. Benchmarks and examples are added to test and experiment parallel computations.
- Parallel execution is handled by the orx-parallel crate which is added as an optional dependency. Importantly note that "orx-parallel" requires "std". Therefore, for no-std use cases this features must be excluded. Since "orx-parallel" is added as a default feature, it must be excluded by
--no-default-features.
recursive_set
recursive_set method is defined and implemented for NodeMut. This method provides an expressive way to update the values of a tree where value of a node is a function of its prior value and values of its children. Since the values of its children subsequently depend on their own children, it immediately follows that the value of the node depends on values of all of its descendants that must be computed to be able to compute the node's value.
In addition mutable_recursive_traversal example is created to demonstrate different ways to approach to this problem.
Fixes 159.
2024edition
Migration to edition2024.
CI action is added.
Upgrade PseudoDefault dependency
Merge pull request #156 from orxfun/Upgrade-PseudoDefault-dependency Upgrade PseudoDefault dependency
Dual license
Merge pull request #155 from orxfun/dual-licenses dual licenses