From 4d0dc0bf44523f3734baba7c646ddc9ac7952b10 Mon Sep 17 00:00:00 2001 From: Mizar Date: Wed, 25 Jan 2023 17:28:25 +0900 Subject: [PATCH] segtree: get_slice --- src/segtree.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/segtree.rs b/src/segtree.rs index c48285c..e79c74e 100644 --- a/src/segtree.rs +++ b/src/segtree.rs @@ -127,7 +127,7 @@ impl From> for Segtree { let log = ceil_pow2(n as u32) as usize; let size = 1 << log; let mut d = vec![M::identity(); 2 * size]; - d[size..(size + n)].clone_from_slice(&v); + d[size..][..n].clone_from_slice(&v); let mut ret = Segtree { n, size, log, d }; for i in (1..size).rev() { ret.update(i); @@ -170,6 +170,10 @@ impl Segtree { self.d[p + self.size].clone() } + pub fn get_slice(&self) -> &[M::S] { + &self.d[self.size..][..self.n] + } + pub fn prod(&self, range: R) -> M::S where R: RangeBounds,