-
Notifications
You must be signed in to change notification settings - Fork 27
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 From<Vec<T>>
and FromIterator
for FenwickTree
#103
base: master
Are you sure you want to change the base?
Implement From<Vec<T>>
and FromIterator
for FenwickTree
#103
Conversation
@@ -1,20 +1,22 @@ | |||
use std::{iter::FromIterator, ops::AddAssign}; | |||
|
|||
use crate::num_traits::Zero; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Implement
From<Vec<T>>
andFromIterator
forFenwickTree
#103 : ImplementFrom<Vec<T>>
andFromIterator
forFenwickTree
- Avoid
Clone
inFenwickTree
#104 : AvoidClone
inFenwickTree
These appear to be changes that need not specifically rely on #102. Check out the application examples below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous example, we used the Default trait, but now #55 makes it easier to use the Zero trait in user-defined structures as well, the need for the num crate may be lessened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you rely on internal_type_traits::Zero traits, you will likely need to make this change to check for expand, FYI.
https://github.com/rust-lang-ja/ac-library-rs/compare/7e99fd2941976764b4e7925898fae7cc77890885...mizar:ac-library-rs:fd6bf7f453113c2b1ef5c7dd81c0955de2836cbd?expand=1
We can now construct a new fenwick tree from a vector and an iterator.
What is more, it initializes in an O(n) time (see also this article).
This PR depends on #102, because we cannot implement these traits if we require an additive identity
e
.