Skip to content

Implement Clone for LazySegtree and discuss the Debug Implementation #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
NotLeonian opened this issue Feb 22, 2025 · 2 comments · May be fixed by #171
Open

Implement Clone for LazySegtree and discuss the Debug Implementation #143

NotLeonian opened this issue Feb 22, 2025 · 2 comments · May be fixed by #171

Comments

@NotLeonian
Copy link
Contributor

Implement the Clone trait for LazySegtree.
Since both MapMonoid::F and <F::M as Monoid>::S have the Clone constraint, it can be derived.

Additionally, LazySegtree already has a Debug implementation, but there is a comment saying // TODO is it useful? .
It may be necessary to discuss whether to implement Debug for FenwickTree and Segtree based on this implementation.

@NotLeonian
Copy link
Contributor Author

The Debug trait implementation might be better if it follows the format discussed in FenwickTree #145 to keep things consistent.

Also, personally, I feel that it might be a bit confusing for users if the fmt function does not display the struct name.

@NotLeonian
Copy link
Contributor Author

I'd like to propose a few improvements to the current Debug implementation for LazySegtree.

Currently, the fields n, size, and log are not displayed. I think it would be better to include them in the output as well.

Additionally, since the current implementation uses tabs and newlines manually rather than relying on helper methods like debug_struct, the output remains the same even when using the alternate flag ({:#?}).
To address this, I would like to update the implementation to use helpers such as debug_struct to provide proper formatting and alternate flag support.

More specifically, I’m thinking of displaying d and lz separately, formatting each in a way similar to a two-dimensional vector grouped by segment length.

To help clarify what I have in mind, I’m also considering opening a draft PR with a sample implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant