Skip to content

Commit 678b88d

Browse files
committed
defaults fixed
1 parent 19e8fdd commit 678b88d

File tree

4 files changed

+14
-83
lines changed

4 files changed

+14
-83
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "orx-tree"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
edition = "2021"
55
authors = ["orxfun <orx.ugur.arikan@gmail.com>"]
66
description = "A beautiful tree 🌳 with convenient and efficient growth, mutation and traversal features."
@@ -24,6 +24,6 @@ serde_json = { version = "1.0.137", default-features = false, features = [
2424
] }
2525

2626
[features]
27-
default = ["std", "serde"]
27+
default = []
2828
std = []
2929
serde = ["dep:serde"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ On the other hand, [`node.ancestors()`](https://docs.rs/orx-tree/latest/orx_tree
3838

3939
We also can walk the tree in an alternative desired order by using methods such as:
4040

41-
* [`node.child(child_idx)`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.child), [`node.children()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.children), [`node.children_mut()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.children_mut), [`node.into_child(child_idx)`]((https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.into_child))
42-
* [`node.parent()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.parent), [`node.into_parent()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.into_parent), etc.
41+
* [`node.child(child_idx)`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.child), [`node.children()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.children), [`node.children_mut()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.children_mut), [`node.into_child_mut(child_idx)`](https://docs.rs/orx-tree/latest/orx_tree/struct.NodeMut.html#method.into_child_mut)
42+
* [`node.parent()`](https://docs.rs/orx-tree/latest/orx_tree/trait.NodeRef.html#method.parent), [`node.into_parent_mut()`](https://docs.rs/orx-tree/latest/orx_tree/struct.NodeMut.html#method.into_parent_mut), etc.
4343

4444
The tree naturally implements [`Collection`](https://docs.rs/orx-iterable/latest/orx_iterable/trait.Collection.html) and [`CollectionMut`](https://docs.rs/orx-iterable/latest/orx_iterable/trait.CollectionMut.html) providing iterators via `iter` and `iter_mut` methods. Since the tree is not a linear data structure, these iterators yield elements in an arbitrary (but deterministic) order. The following are some example cases where the traversal order is not important, and hence, these iterators are useful:
4545

src/node_mut.rs

Lines changed: 10 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,19 +2256,12 @@ where
22562256
/// // | | ╱ ╲
22572257
/// // 8 9 10 11
22582258
///
2259-
/// let mut tree = DynTree::new(1);
2260-
///
2261-
/// let mut root = tree.root_mut();
2262-
/// let [id2, id3] = root.push_children([2, 3]);
2263-
///
2264-
/// let mut n2 = tree.node_mut(&id2);
2265-
/// let [id4, _] = n2.push_children([4, 5]);
2266-
///
2259+
/// // keep indices valid during removals
2260+
/// let mut tree = DynTree::new(1).into_lazy_reclaim();
2261+
/// let [id2, id3] = tree.root_mut().push_children([2, 3]);
2262+
/// let [id4, _] = tree.node_mut(&id2).push_children([4, 5]);
22672263
/// tree.node_mut(&id4).push_child(8);
2268-
///
2269-
/// let mut n3 = tree.node_mut(&id3);
2270-
/// let [id6, id7] = n3.push_children([6, 7]);
2271-
///
2264+
/// let [id6, id7] = tree.node_mut(&id3).push_children([6, 7]);
22722265
/// tree.node_mut(&id6).push_child(9);
22732266
/// tree.node_mut(&id7).push_children([10, 11]);
22742267
///
@@ -2350,19 +2343,12 @@ where
23502343
/// // | | ╱ ╲
23512344
/// // 8 9 10 11
23522345
///
2353-
/// let mut tree = DynTree::new(1);
2354-
///
2355-
/// let mut root = tree.root_mut();
2356-
/// let [id2, id3] = root.push_children([2, 3]);
2357-
///
2358-
/// let mut n2 = tree.node_mut(&id2);
2359-
/// let [id4, _] = n2.push_children([4, 5]);
2360-
///
2346+
/// // keep indices valid during removals
2347+
/// let mut tree = DynTree::new(1).into_lazy_reclaim();
2348+
/// let [id2, id3] = tree.root_mut().push_children([2, 3]);
2349+
/// let [id4, _] = tree.node_mut(&id2).push_children([4, 5]);
23612350
/// tree.node_mut(&id4).push_child(8);
2362-
///
2363-
/// let mut n3 = tree.node_mut(&id3);
2364-
/// let [id6, id7] = n3.push_children([6, 7]);
2365-
///
2351+
/// let [id6, id7] = tree.node_mut(&id3).push_children([6, 7]);
23662352
/// tree.node_mut(&id6).push_child(9);
23672353
/// tree.node_mut(&id7).push_children([10, 11]);
23682354
///
@@ -2841,56 +2827,3 @@ where
28412827
.map(|p| NodeMut::new(self.col, p))
28422828
}
28432829
}
2844-
2845-
#[test]
2846-
fn abc() {
2847-
use crate::*;
2848-
use alloc::vec::Vec;
2849-
2850-
// 1
2851-
// ╱ ╲
2852-
// ╱ ╲
2853-
// 2 3
2854-
// ╱ ╲ ╱ ╲
2855-
// 4 5 6 7
2856-
// | | ╱ ╲
2857-
// 8 9 10 11
2858-
let mut tree = DynTree::new(1).into_lazy_reclaim(); // ensure index validity
2859-
let [id2, id3] = tree.root_mut().push_children([2, 3]);
2860-
let [id4, _] = tree.node_mut(&id2).push_children([4, 5]);
2861-
tree.node_mut(&id4).push_child(8);
2862-
let [id6, id7] = tree.node_mut(&id3).push_children([6, 7]);
2863-
tree.node_mut(&id6).push_child(9);
2864-
tree.node_mut(&id7).push_children([10, 11]);
2865-
2866-
// let's move subtree rooted at n2 into new tree: tree2
2867-
// 2
2868-
// ╱ ╲
2869-
// 4 5
2870-
// |
2871-
// 8
2872-
let tree2: DynTree<_> = tree.node_mut(&id2).into_new_tree();
2873-
let bfs: Vec<_> = tree2.root().walk::<Bfs>().copied().collect();
2874-
assert_eq!(bfs, [2, 4, 5, 8]);
2875-
2876-
// let's move subtree rooted at n7 into new tree: tree7
2877-
// this time, the target tree is a BinaryTree
2878-
// 7
2879-
// ╱ ╲
2880-
// 10 11
2881-
let tree7: BinaryTree<_> = tree.node_mut(&id7).into_new_tree();
2882-
let bfs: Vec<_> = tree7.root().walk::<Bfs>().copied().collect();
2883-
assert_eq!(bfs, [7, 10, 11]);
2884-
2885-
// these subtrees are removed from the original tree
2886-
// 1
2887-
// ╲
2888-
// ╲
2889-
// 3
2890-
// ╱
2891-
// 6
2892-
// |
2893-
// 9
2894-
let bfs: Vec<_> = tree.root().walk::<Bfs>().copied().collect();
2895-
assert_eq!(bfs, [1, 3, 6, 9]);
2896-
}

src/traversal/post_order/iter_ptr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ where
108108
None => return None,
109109
Some((ptr, child_idx)) => {
110110
let node = unsafe { &*ptr.ptr() };
111-
std::dbg!(child_idx);
112111
let child_ptr = node.next().get_ptr(*child_idx).cloned();
113-
std::dbg!("ABC");
114112
match child_ptr {
115113
Some(child_ptr) => self.move_deeper(child_ptr),
116114
None => {

0 commit comments

Comments
 (0)