Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
3c25ec6
initiate test for walk with
orxfun Dec 4, 2025
45c67c6
revise root method lifetimes
orxfun Dec 4, 2025
3770a5d
fix root_mut method lifetimes
orxfun Dec 4, 2025
3bd229e
clippy fix
orxfun Dec 5, 2025
466c007
explicit lifetimes for all node getters from Tree
orxfun Dec 5, 2025
88ad2fb
remove lifetime bound from noderef references, as it is already a ref…
orxfun Dec 5, 2025
e1010a0
define lifetime relations of traverser, node reference and returned i…
orxfun Dec 5, 2025
213305f
add node_ref_lifetime_tests
orxfun Dec 5, 2025
f13e846
define explicit lifetimes for NodeRef::walk and traversers
orxfun Dec 5, 2025
0c806e5
add find_walk lifetime test
orxfun Dec 5, 2025
340f7f4
add find_walk_par lifetime test
orxfun Dec 5, 2025
86b050a
define custom_walk lifetimes
orxfun Dec 5, 2025
79d67df
add find_custom_walk_par lifetime tests
orxfun Dec 5, 2025
22e9925
explicit lifetime relations for walk_with_par
orxfun Dec 5, 2025
5d76250
explicit lifetimes for paths, leaves and indices iterators of NodeRef…
orxfun Dec 5, 2025
5e54ca8
fix
orxfun Dec 5, 2025
acd8dbd
explicit lifetimes for find_paths_par
orxfun Dec 5, 2025
864c19a
explicit lifetimes for paths_with
orxfun Dec 5, 2025
af1d74c
define explicit lifetime relations for paths_par_with iterator
orxfun Dec 5, 2025
dfc9ef5
explicit leaves_par lifetime relations
orxfun Dec 5, 2025
be8e711
explicit lifetimes for NodeRef::leaves_with and leaves_with_par
orxfun Dec 5, 2025
cd0016c
explicit lifetimes for NodeRef::indices_with
orxfun Dec 5, 2025
d1936a6
explicit lifetime relations for NodeRef::children
orxfun Dec 5, 2025
0a10d94
explicit lifetimes for NodeRef::children_par
orxfun Dec 5, 2025
ff426ac
simplify children lifetimes
orxfun Dec 5, 2025
70c8186
fix NodeRef::ancestors lifetime relations
orxfun Dec 5, 2025
1dc5d07
fix ancestors_par lifetime relations
orxfun Dec 5, 2025
a038883
simplify NodeRef::custom_walk lifetimes
orxfun Dec 5, 2025
aa876c9
simplify NodeRef::walk lifetimes
orxfun Dec 5, 2025
0fc5dda
simplify NodeRef::walk_par lifetimes
orxfun Dec 5, 2025
fdc6856
simplify TraverserCore::iter_with_storage lifetimes
orxfun Dec 5, 2025
cc37b0e
define iter_with_owned_storage lifetime independent of the node ref l…
orxfun Dec 5, 2025
883300a
fix lifetime of returned walk iterator
orxfun Dec 5, 2025
e5bf719
fix custom walk lifetimes
orxfun Dec 5, 2025
fdfba78
revise walk_with lifetime relations with traverser
orxfun Dec 5, 2025
05557f0
relax lifetime requirement on NodeRef reference
orxfun Dec 5, 2025
7b70d21
require tree variants to be Send and Sync
orxfun Dec 5, 2025
09d5e40
require memory reclaimers to implement sync
orxfun Dec 5, 2025
b905870
fix NodeRef self referene lifetimes for iterator creating methods
orxfun Dec 5, 2025
5c0417f
relax NodeRef::clone_as_tree self reference lifetime
orxfun Dec 5, 2025
2c51c23
break lifetime dependencies to NodeRef, link to tree lifetime instead
orxfun Dec 5, 2025
19f0989
remove lifetime from RefsChildren::ChildrenPtrIter items
orxfun Dec 5, 2025
b758aa3
simplify parallel children iterator
orxfun Dec 5, 2025
05c53fd
fix children iterator's lifetime
orxfun Dec 5, 2025
4a4744e
fix children_par lifetime
orxfun Dec 5, 2025
6ff1403
fix NodeRef::ancestors lifetime
orxfun Dec 5, 2025
b91db75
fix ancestors_par lifetime
orxfun Dec 5, 2025
390c5e4
create find_custom_walk_mut lifetime test
orxfun Dec 5, 2025
1622a5c
correct walk_mut lifetime relations
orxfun Dec 5, 2025
738253f
revise NodeMut self lifetimes
orxfun Dec 5, 2025
25f476d
fix leaves_mut lifetime
orxfun Dec 5, 2025
cdcd23c
fix custom_walk_mut self lifetime
orxfun Dec 5, 2025
2416e39
clean up
orxfun Dec 5, 2025
a4b9452
update selfref-col dependency to the develop branch
orxfun Dec 5, 2025
73ab996
update test documentation
orxfun Dec 5, 2025
7f5b42f
fix node_ref_lifetime_tests for no default fetaures case
orxfun Dec 5, 2025
b705aab
clippy fixes
orxfun Dec 5, 2025
cdadb43
revision
orxfun Dec 6, 2025
abfa8b4
Update tests/iterator_lifetimes.rs
orxfun Dec 6, 2025
fd1607c
Update tests/iterator_lifetimes.rs
orxfun Dec 6, 2025
252fa79
Update tests/iterator_lifetimes.rs
orxfun Dec 6, 2025
24f9143
Update tests/iterator_lifetimes.rs
orxfun Dec 6, 2025
d952f21
Update src/traversal/traverser_core.rs
orxfun Dec 6, 2025
7f54c0d
Update src/traversal/traverser_core.rs
orxfun Dec 6, 2025
1788ae4
remove inherited lifetime constraint
orxfun Dec 6, 2025
fb71540
consistent argument naming
orxfun Dec 6, 2025
17d11e1
remove inherited lifetime bounds
orxfun Dec 6, 2025
a90fd3d
explicit lifetimes for NodeMut::children_mut
orxfun Dec 6, 2025
c8b75f2
upgrade selfref-col dependency
orxfun Dec 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ orx-self-or = "1.2.0"
serde = { version = "1.0.228", optional = true, default-features = false }
orx-pinned-vec = { version = "3.21.0", default-features = false }
orx-split-vec = { version = "3.22.0", default-features = false }
orx-selfref-col = { version = "3.0.0", default-features = false }
orx-selfref-col = { version = "3.1.0", default-features = false }
orx-concurrent-iter = { version = "3.3.0", default-features = false }
orx-parallel = { version = "3.4.0", default-features = false, optional = true }

Expand Down
10 changes: 10 additions & 0 deletions src/dary/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ pub struct Dary<const D: usize, T> {
p: PhantomData<T>,
}

/// # SAFETY
///
/// Tree variants do not hold any data; and hence, safe to sync.
unsafe impl<const D: usize, T> Sync for Dary<D, T> {}

/// # SAFETY
///
/// Tree variants do not hold any data; and hence, safe to sync.
unsafe impl<const D: usize, T> Send for Dary<D, T> {}

impl<const D: usize, T> Variant for Dary<D, T> {
type Item = T;

Expand Down
10 changes: 10 additions & 0 deletions src/dyn/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ pub struct Dyn<T> {
p: PhantomData<T>,
}

/// # SAFETY
///
/// Tree variants do not hold any data, safe to send or sync.
unsafe impl<T> Sync for Dyn<T> {}

/// # SAFETY
///
/// Tree variants do not hold any data, safe to send or sync.
unsafe impl<T> Send for Dyn<T> {}

impl<T> Variant for Dyn<T> {
type Item = T;

Expand Down
4 changes: 2 additions & 2 deletions src/iter/children_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
type Item = NodeMut<'b, V, M, P, NodeMutDown>;

fn next(&mut self) -> Option<Self::Item> {
self.children_ptr.next().map(|p| self.next_child(*p))
self.children_ptr.next().map(|p| self.next_child(p))
}

fn size_hint(&self) -> (usize, Option<usize>) {
Expand Down Expand Up @@ -79,6 +79,6 @@ where
'a: 'b,
{
fn next_back(&mut self) -> Option<Self::Item> {
self.children_ptr.next_back().map(|p| self.next_child(*p))
self.children_ptr.next_back().map(|p| self.next_child(p))
}
}
69 changes: 40 additions & 29 deletions src/node_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,13 +1645,13 @@ where

match parent_ptr {
None => {
let first_child = self.node().next().children_ptr().next().cloned();
let first_child = self.node().next().children_ptr().next();
self.col.ends_mut().set(first_child);
}
Some(parent_ptr) => {
let parent = unsafe { &mut *parent_ptr.ptr_mut() };
parent.next_mut().remove_at(sibling_idx);
for child_ptr in self.node().next().children_ptr().rev().cloned() {
for child_ptr in self.node().next().children_ptr().rev() {
parent.next_mut().insert(sibling_idx, child_ptr);
}
}
Expand Down Expand Up @@ -1697,7 +1697,7 @@ where
/// let bfs: Vec<_> = tree.root().walk::<Bfs>().copied().collect();
/// assert_eq!(bfs, [1, 2, 3, 4, 5, 8]);
/// ```
pub fn remove_children(&mut self) {
pub fn remove_children(&'a mut self) {
for c in self.children_mut() {
_ = c.prune();
}
Expand Down Expand Up @@ -1769,9 +1769,13 @@ where
/// assert_eq!(all_values, [101, 202, 303, 4, 5, 406, 507]);
/// ```
#[allow(clippy::missing_panics_doc)]
pub fn custom_walk_mut<F>(&mut self, next_node: F) -> impl Iterator<Item = &'a mut V::Item>
pub fn custom_walk_mut<'t, F>(
&mut self,
next_node: F,
) -> impl Iterator<Item = &'a mut V::Item> + 't
where
F: Fn(Node<'a, V, M, P>) -> Option<Node<'a, V, M, P>>,
F: Fn(Node<'a, V, M, P>) -> Option<Node<'a, V, M, P>> + 't,
'a: 't,
{
let iter_ptr = CustomWalkIterPtr::new(self.col(), Some(self.node_ptr()), next_node);
iter_ptr.map(|ptr| {
Expand Down Expand Up @@ -2047,10 +2051,9 @@ where
/// assert_eq!(dfs, [1, 2, 4, 8, 5, 9, 3, 6, 10, 7, 11, 12]);
/// ```
pub fn children_mut(
&mut self,
) -> impl ExactSizeIterator<Item = NodeMut<'_, V, M, P, NodeMutDown>>
+ DoubleEndedIterator
+ use<'_, 'a, V, M, P, MO> {
&'a mut self,
) -> impl ExactSizeIterator<Item = NodeMut<'a, V, M, P, NodeMutDown>> + DoubleEndedIterator
{
ChildrenMutIter::new(self.col, unsafe { self.node_ptr.ptr() })
}

Expand Down Expand Up @@ -2127,9 +2130,11 @@ where
/// assert_eq!(post_order.next(), Some(&mut 4)); // ...
/// }
/// ```
pub fn walk_mut<T>(&'a mut self) -> impl Iterator<Item = &'a mut V::Item>
pub fn walk_mut<'t, T>(&mut self) -> impl Iterator<Item = &'a mut V::Item> + 't
where
T: Traverser<OverData>,
T::Storage<V>: 't,
'a: 't,
{
T::iter_mut_with_owned_storage::<V, M, P, MO>(self)
}
Expand Down Expand Up @@ -2272,13 +2277,14 @@ where
/// ]
/// );
/// ```
pub fn walk_mut_with<T, O>(
&'a mut self,
traverser: &'a mut T,
) -> impl Iterator<Item = OverItemMut<'a, V, O, M, P>>
pub fn walk_mut_with<'t, T, O>(
&mut self,
traverser: &'t mut T,
) -> impl Iterator<Item = OverItemMut<'a, V, O, M, P>> + 't
where
O: OverMut,
T: Traverser<O>,
'a: 't,
{
traverser.iter_mut(self)
}
Expand Down Expand Up @@ -2522,13 +2528,14 @@ where
/// ]
/// );
/// ```
pub fn into_walk_with<T, O>(
pub fn into_walk_with<'t, T, O>(
self,
traverser: &'a mut T,
) -> impl Iterator<Item = OverItemInto<'a, V, O>>
traverser: &'t mut T,
) -> impl Iterator<Item = OverItemInto<'a, V, O>> + 't
where
O: OverMut,
T: Traverser<O>,
'a: 't,
{
traverser.into_iter(self)
}
Expand Down Expand Up @@ -2598,10 +2605,12 @@ where
/// let leaves: Vec<_> = n3.leaves::<PostOrder>().copied().collect();
/// assert_eq!(leaves, [209, 210, 211]);
/// ```
pub fn leaves_mut<T>(&'a mut self) -> impl Iterator<Item = &'a mut V::Item>
pub fn leaves_mut<'t, T>(&mut self) -> impl Iterator<Item = &'a mut V::Item> + 't
where
T: Traverser<OverData>,
T: Traverser<OverData> + 't,
'a: 't,
{
let col = self.col();
T::iter_ptr_with_owned_storage(self.node_ptr())
.filter(|x: &NodePtr<V>| unsafe { &*x.ptr() }.next().is_empty())
.map(|x: NodePtr<V>| {
Expand All @@ -2611,7 +2620,7 @@ where
M,
P,
&'a mut V::Item,
>(self.col(), x)
>(col, x)
})
}

Expand Down Expand Up @@ -2734,23 +2743,24 @@ where
/// [(2, &205), (3, &308), (3, &309), (3, &310), (3, &311)]
/// );
/// ```
pub fn leaves_mut_with<T, O>(
&'a mut self,
traverser: &'a mut T,
) -> impl Iterator<Item = OverItemMut<'a, V, O, M, P>>
pub fn leaves_mut_with<'t, T, O>(
&mut self,
traverser: &'t mut T,
) -> impl Iterator<Item = OverItemMut<'a, V, O, M, P>> + 't
where
O: OverMut,
T: Traverser<O>,
'a: 't,
{
let col = self.col();
T::iter_ptr_with_storage(self.node_ptr(), traverser.storage_mut())
.filter(|x| {
let ptr: &NodePtr<V> = O::Enumeration::node_data(x);
unsafe { &*ptr.ptr() }.next().is_empty()
})
.map(|x| {
O::Enumeration::from_element_ptr_mut::<'a, V, M, P, O::NodeItemMut<'a, V, M, P>>(
self.col(),
x,
col, x,
)
})
}
Expand Down Expand Up @@ -2932,13 +2942,14 @@ where
///
/// assert!(tree.is_empty());
/// ```
pub fn into_leaves_with<T, O>(
pub fn into_leaves_with<'t, T, O>(
self,
traverser: &'a mut T,
) -> impl Iterator<Item = OverItemInto<'a, V, O>>
traverser: &'t mut T,
) -> impl Iterator<Item = OverItemInto<'a, V, O>> + 't
where
O: OverMut,
T: Traverser<O>,
'a: 't,
{
T::into_iter_with_storage_filtered(self, traverser.storage_mut(), |x| {
let ptr = <O::Enumeration as Enumeration>::node_data(x);
Expand Down
Loading