Rename context parameters to cx in sum_tree

This commit is contained in:
Max Brunsfeld 2021-05-28 15:24:33 -07:00
parent f6e2754494
commit 173f99748d
2 changed files with 70 additions and 75 deletions

View file

@ -342,33 +342,28 @@ where
S: SeekDimension<'a, T::Summary>,
U: Dimension<'a, T::Summary>,
{
pub fn seek(
&mut self,
pos: &S,
bias: SeekBias,
ctx: &<T::Summary as Summary>::Context,
) -> bool {
pub fn seek(&mut self, pos: &S, bias: SeekBias, cx: &<T::Summary as Summary>::Context) -> bool {
self.reset();
self.seek_internal::<()>(pos, bias, &mut SeekAggregate::None, ctx)
self.seek_internal::<()>(pos, bias, &mut SeekAggregate::None, cx)
}
pub fn seek_forward(
&mut self,
pos: &S,
bias: SeekBias,
ctx: &<T::Summary as Summary>::Context,
cx: &<T::Summary as Summary>::Context,
) -> bool {
self.seek_internal::<()>(pos, bias, &mut SeekAggregate::None, ctx)
self.seek_internal::<()>(pos, bias, &mut SeekAggregate::None, cx)
}
pub fn slice(
&mut self,
end: &S,
bias: SeekBias,
ctx: &<T::Summary as Summary>::Context,
cx: &<T::Summary as Summary>::Context,
) -> SumTree<T> {
let mut slice = SeekAggregate::Slice(SumTree::new());
self.seek_internal::<()>(end, bias, &mut slice, ctx);
self.seek_internal::<()>(end, bias, &mut slice, cx);
if let SeekAggregate::Slice(slice) = slice {
slice
} else {
@ -376,10 +371,10 @@ where
}
}
pub fn suffix(&mut self, ctx: &<T::Summary as Summary>::Context) -> SumTree<T> {
pub fn suffix(&mut self, cx: &<T::Summary as Summary>::Context) -> SumTree<T> {
let extent = self.tree.extent::<S>();
let mut slice = SeekAggregate::Slice(SumTree::new());
self.seek_internal::<()>(&extent, SeekBias::Right, &mut slice, ctx);
self.seek_internal::<()>(&extent, SeekBias::Right, &mut slice, cx);
if let SeekAggregate::Slice(slice) = slice {
slice
} else {
@ -391,13 +386,13 @@ where
&mut self,
end: &S,
bias: SeekBias,
ctx: &<T::Summary as Summary>::Context,
cx: &<T::Summary as Summary>::Context,
) -> D
where
D: Dimension<'a, T::Summary>,
{
let mut summary = SeekAggregate::Summary(D::default());
self.seek_internal(end, bias, &mut summary, ctx);
self.seek_internal(end, bias, &mut summary, cx);
if let SeekAggregate::Summary(summary) = summary {
summary
} else {
@ -410,12 +405,12 @@ where
target: &S,
bias: SeekBias,
aggregate: &mut SeekAggregate<T, D>,
ctx: &<T::Summary as Summary>::Context,
cx: &<T::Summary as Summary>::Context,
) -> bool
where
D: Dimension<'a, T::Summary>,
{
debug_assert!(target.cmp(&self.seek_dimension, ctx) >= Ordering::Equal);
debug_assert!(target.cmp(&self.seek_dimension, cx) >= Ordering::Equal);
let mut containing_subtree = None;
if self.did_seek {
@ -435,7 +430,7 @@ where
let mut child_end = self.seek_dimension.clone();
child_end.add_summary(&child_summary);
let comparison = target.cmp(&child_end, ctx);
let comparison = target.cmp(&child_end, cx);
if comparison == Ordering::Greater
|| (comparison == Ordering::Equal && bias == SeekBias::Right)
{
@ -444,7 +439,7 @@ where
match aggregate {
SeekAggregate::None => {}
SeekAggregate::Slice(slice) => {
slice.push_tree(child_tree.clone(), ctx);
slice.push_tree(child_tree.clone(), cx);
}
SeekAggregate::Summary(summary) => {
summary.add_summary(child_summary);
@ -477,7 +472,7 @@ where
let mut item_end = self.seek_dimension.clone();
item_end.add_summary(item_summary);
let comparison = target.cmp(&item_end, ctx);
let comparison = target.cmp(&item_end, cx);
if comparison == Ordering::Greater
|| (comparison == Ordering::Equal && bias == SeekBias::Right)
{
@ -491,7 +486,7 @@ where
slice_items_summary
.as_mut()
.unwrap()
.add_summary(item_summary, ctx);
.add_summary(item_summary, cx);
}
SeekAggregate::Summary(summary) => {
summary.add_summary(item_summary);
@ -506,7 +501,7 @@ where
items: slice_items,
item_summaries: slice_item_summaries,
})),
ctx,
cx,
);
}
break 'outer;
@ -521,7 +516,7 @@ where
items: slice_items,
item_summaries: slice_item_summaries,
})),
ctx,
cx,
);
}
}
@ -551,7 +546,7 @@ where
let mut child_end = self.seek_dimension.clone();
child_end.add_summary(child_summary);
let comparison = target.cmp(&child_end, ctx);
let comparison = target.cmp(&child_end, cx);
if comparison == Ordering::Greater
|| (comparison == Ordering::Equal && bias == SeekBias::Right)
{
@ -560,7 +555,7 @@ where
match aggregate {
SeekAggregate::None => {}
SeekAggregate::Slice(slice) => {
slice.push_tree(child_trees[index].clone(), ctx);
slice.push_tree(child_trees[index].clone(), cx);
}
SeekAggregate::Summary(summary) => {
summary.add_summary(child_summary);
@ -597,7 +592,7 @@ where
let mut child_end = self.seek_dimension.clone();
child_end.add_summary(item_summary);
let comparison = target.cmp(&child_end, ctx);
let comparison = target.cmp(&child_end, cx);
if comparison == Ordering::Greater
|| (comparison == Ordering::Equal && bias == SeekBias::Right)
{
@ -610,7 +605,7 @@ where
slice_items_summary
.as_mut()
.unwrap()
.add_summary(item_summary, ctx);
.add_summary(item_summary, cx);
slice_item_summaries.push(item_summary.clone());
}
SeekAggregate::Summary(summary) => {
@ -636,7 +631,7 @@ where
items: slice_items,
item_summaries: slice_item_summaries,
})),
ctx,
cx,
);
}
}
@ -658,9 +653,9 @@ where
if let Some(summary) = self.item_summary() {
end.add_summary(summary);
}
target.cmp(&end, ctx) == Ordering::Equal
target.cmp(&end, cx) == Ordering::Equal
} else {
target.cmp(&self.seek_dimension, ctx) == Ordering::Equal
target.cmp(&self.seek_dimension, cx) == Ordering::Equal
}
}
}