WIP: remove unused helpers for NodeIndex

This commit is contained in:
Qyriad 2024-10-16 12:15:49 -06:00
parent 1ca498b346
commit aa88e29f2c

View file

@ -193,26 +193,22 @@ impl NodeIndex {
return false; return false;
} }
if other.depth < self.depth {
return false;
}
other = other.parent(); other = other.parent();
} }
} }
/// Returns the right-most descendent of the current node for a tree of `DEPTH` depth. /// The inverse of [`NodeIndex::is_ancestor_of`], except that it does not include itself.
pub const fn rightmost_descendent<const DEPTH: u8>(mut self) -> Self { pub fn is_descendent_of(self, other: Self) -> bool {
while self.depth() < DEPTH { self.depth != other.depth && self.value != other.value && other.contains(self)
self = self.right_child();
}
self
} }
/// Returns the left-most descendent of the current node for a tree of `DEPTH` depth. /// Returns `true` if and only if `other` is an ancestor of the current node.
pub const fn leftmost_descendent<const DEPTH: u8>(mut self) -> Self { pub fn is_ancestor_of(self, other: Self) -> bool {
while self.depth() < DEPTH { self.depth != other.depth && self.value != other.value && self.contains(other)
self = self.left_child();
}
self
} }
// PROVIDERS // PROVIDERS