This commit is contained in:
2024-06-10 15:08:18 -04:00
parent 974f9bbd82
commit ec09d0aefa

View File

@@ -120,13 +120,14 @@ impl RoyaltyTree {
}
self
}
fn drill(&mut self, index: usize) {
fn get_royalty(&mut self, index: usize) -> FiNum {
let mut f=self.forefather();
while f!=index {
self.capture0(f);
f=if f>index { wt_left(f).unwrap() } else { wt_right(f).unwrap() }
}
self.capture0(f);
self.tree[index].acc
}
fn capture(&mut self, index: usize) {
let f=self.forefather();
@@ -155,9 +156,10 @@ impl RoyaltyTree {
fn forefather(&self) -> usize {
wt_forefather(self.tree.len()-1)
}
fn dump(&self) {
fn dump(&mut self) {
for index in 0..self.tree.len() {
println!("Index {} Weight {} Lazy {} Acc {}",index,self.tree[index].weight,self.tree[index].lazy,self.tree[index].acc);
let roy=self.get_royalty(index);
println!("Index {} Weight {} Lazy {} Acc {} Royalty {}",index,self.tree[index].weight,self.tree[index].lazy,self.tree[index].acc,roy);
}
}
}