-
Notifications
You must be signed in to change notification settings - Fork 29
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
Implement Clone
and Debug
for FenwickTree
#145
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 |
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: