-
Notifications
You must be signed in to change notification settings - Fork 29
Implement Clone
and Debug
for FenwickTree
#145
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
Comments
We may also accept the "alternate" flag ( |
Thank you! That certainly sounds like a better approach. |
That's what I obfuscated indeed 😜 There are two rooms and we need to discuss which to print for each of them.
Alternatively, one may delegate the latter format to |
I see, that makes a lot of sense. If we go with the ASCII art-like format, it would be nice to update |
I disagree with implementing
|
Considering that this is not a library for public use but rather competitive-programming oriented, sometimes it may be good idea not follow the convention in standard Rust language. A notable example is that we allow arithmetic operations of modint against arbitrary integer types, which doesn't follow usual Rust philosophy. Of course, whether to provide the visualization feature via |
I'd like to share my current thoughts on the output format for the Unlike graph-related data structures, I believe users of When debugging a cumulative sum implemented using a Also, since the alternate flag for To help clarify what I have in mind, I’m also considering opening a draft PR with a sample implementation. |
Since there seems to be no objection to implementing the |
I agree with the suggestion to implement the In the draft PR I previously created, I had committed both the |
One idea would be to create a commit and PR that implements only the |
Thank you. |
I unintentionally closed the previous draft PR by renaming its branch. Although the rebase was successful, the commit message still refers to the original implementation (including I plan to keep the rebased branch in my repository for reference, but I propose creating a new branch from scratch to open a fresh draft PR. Thank you for your understanding... |
Implement the
Clone
andDebug
traits forFenwickTree
.For the
Clone
trait, it should be enough to add aClone
trait bound toT
and write an explicitimpl
.For the
Debug
trait, I think that discussion is needed regarding the output format.Unlike
Segtree
andLazySegtree
,FenwickTree
does not haveself.log
.Additionally, in a Fenwick Tree, the structure does not explicitly store all segments like a Segment Tree or Lazy Segment Tree. This difference causes gaps in the tree representation, making it problematic to use the same output format.
Therefore, I propose an output format that includes
self.n
,self.e
, and the return values of the accum function for1..=self.n
.For example, if
self.n = 10
,self.e = 0
, and the array is[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
, the output could be one of the following:With this implementation, the required trait bounds for
T
are limited toClone + Debug + std::ops::AddAssign<T>
.The text was updated successfully, but these errors were encountered: