feat: implement iterators over contents of TieredSmt

This commit is contained in:
Bobbin Threadbare
2023-05-16 00:11:06 -07:00
parent 02673ff87e
commit 21e7a5c07d
4 changed files with 179 additions and 12 deletions

View File

@@ -74,12 +74,26 @@ impl NodeIndex {
Self { depth: 0, value: 0 }
}
/// Computes the value of the sibling of the current node.
pub fn sibling(mut self) -> Self {
/// Computes sibling index of the current node.
pub const fn sibling(mut self) -> Self {
self.value ^= 1;
self
}
/// Returns left child index of the current node.
pub const fn left_child(mut self) -> Self {
self.depth += 1;
self.value <<= 1;
self
}
/// Returns right child index of the current node.
pub const fn right_child(mut self) -> Self {
self.depth += 1;
self.value = (self.value << 1) + 1;
self
}
// PROVIDERS
// --------------------------------------------------------------------------------------------