From 56af51ed81d9419dae3675c9fda8ae524a153a69 Mon Sep 17 00:00:00 2001 From: Moritz Hoffmann Date: Wed, 1 Nov 2023 15:25:08 -0400 Subject: [PATCH] Implement Columnation for PointStamp This change implements support for `Columnation` for `PointStamp`. --- src/dynamic/pointstamp.rs | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/dynamic/pointstamp.rs b/src/dynamic/pointstamp.rs index 1c2eb247d..f88377807 100644 --- a/src/dynamic/pointstamp.rs +++ b/src/dynamic/pointstamp.rs @@ -202,3 +202,51 @@ impl Lattice for PointStamp { Self { vector } } } + +use timely::container::columnation::{Columnation, Region}; +impl Columnation for PointStamp { + type InnerRegion = PointStampStack; +} + +/// Stack for PointStamp. Part of Columnation implementation. +pub struct PointStampStack( as Columnation>::InnerRegion) +where + ::Item: Columnation; + +impl Default for PointStampStack + where + ::Item: Columnation +{ + #[inline] + fn default() -> Self { + Self(Default::default()) + } +} + +impl Region for PointStampStack + where + ::Item: Columnation +{ + type Item = PointStamp; + + #[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 + Clone { + self.0.reserve_items(items.map(|x| &x.vector)); + } + + fn reserve_regions<'a, I>(&mut self, regions: I) where Self: 'a, I: Iterator + Clone { + self.0.reserve_regions(regions.map(|r| &r.0)); + } + + fn heap_size(&self, callback: impl FnMut(usize, usize)) { + self.0.heap_size(callback); + } +}