Skip to content

Commit

Permalink
Implement Columnation for PointStamp
Browse files Browse the repository at this point in the history
This change implements support for `Columnation` for `PointStamp`.
  • Loading branch information
antiguru committed Nov 1, 2023
1 parent 2b9ac68 commit 56af51e
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/dynamic/pointstamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,51 @@ impl<T: Lattice + Timestamp + Clone> Lattice for PointStamp<T> {
Self { vector }
}
}

use timely::container::columnation::{Columnation, Region};
impl<T: Columnation> Columnation for PointStamp<T> {
type InnerRegion = PointStampStack<T::InnerRegion>;
}

/// Stack for PointStamp. Part of Columnation implementation.
pub struct PointStampStack<R: Region>(<Vec<R::Item> as Columnation>::InnerRegion)
where
<R as Region>::Item: Columnation;

impl<R: Region> Default for PointStampStack<R>
where
<R as Region>::Item: Columnation
{
#[inline]
fn default() -> Self {
Self(Default::default())
}
}

impl<R: Region> Region for PointStampStack<R>
where
<R as Region>::Item: Columnation
{
type Item = PointStamp<R::Item>;

#[inline]
unsafe fn copy(&mut self, item: &Self::Item) -> Self::Item {
Self::Item { vector: self.0.copy(&item.vector) }
}

fn clear(&mut self) {
self.0.clear();
}

fn reserve_items<'a, I>(&mut self, items: I) where Self: 'a, I: Iterator<Item=&'a Self::Item> + Clone {
self.0.reserve_items(items.map(|x| &x.vector));
}

fn reserve_regions<'a, I>(&mut self, regions: I) where Self: 'a, I: Iterator<Item=&'a Self> + Clone {
self.0.reserve_regions(regions.map(|r| &r.0));
}

fn heap_size(&self, callback: impl FnMut(usize, usize)) {
self.0.heap_size(callback);
}
}

0 comments on commit 56af51e

Please sign in to comment.