Skip to content

Commit 51dd0db

Browse files
Implement Debug for LazySegtree
1 parent da2c826 commit 51dd0db

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/lazysegtree.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,32 @@ where
286286
}
287287
}
288288

289+
// TODO is it useful?
290+
use std::fmt::{Debug, Error, Formatter, Write};
291+
impl<F> Debug for LazySegtree<F>
292+
where
293+
F: MapMonoid,
294+
F::F: Debug,
295+
<F::M as Monoid>::S: Debug,
296+
{
297+
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
298+
for i in 0..self.log {
299+
for j in 0..1 << i {
300+
f.write_fmt(format_args!(
301+
"{:?}[{:?}]\t",
302+
self.d[(1 << i) + j],
303+
self.lz[(1 << i) + j]
304+
))?;
305+
}
306+
f.write_char('\n')?;
307+
}
308+
for i in 0..self.size {
309+
f.write_fmt(format_args!("{:?}\t", self.d[self.size + i]))?;
310+
}
311+
Ok(())
312+
}
313+
}
314+
289315
#[cfg(test)]
290316
mod tests {
291317
use crate::{LazySegtree, MapMonoid, Max};

0 commit comments

Comments
 (0)