Implement From<Vec<T>> and FromIterator for FenwickTree#103
Open
TonalidadeHidrica wants to merge 10 commits intorust-lang-ja:masterfrom
Open
Implement From<Vec<T>> and FromIterator for FenwickTree#103TonalidadeHidrica wants to merge 10 commits intorust-lang-ja:masterfrom
From<Vec<T>> and FromIterator for FenwickTree#103TonalidadeHidrica wants to merge 10 commits intorust-lang-ja:masterfrom
Conversation
mizar
reviewed
Mar 27, 2023
| @@ -1,20 +1,22 @@ | |||
| use std::{iter::FromIterator, ops::AddAssign}; | |||
|
|
|||
| use crate::num_traits::Zero; | |||
Collaborator
There was a problem hiding this comment.
- Implement
From<Vec<T>>andFromIteratorforFenwickTree#103 : ImplementFrom<Vec<T>>andFromIteratorforFenwickTree - Avoid
CloneinFenwickTree#104 : AvoidCloneinFenwickTree
These appear to be changes that need not specifically rely on #102. Check out the application examples below.
Collaborator
There was a problem hiding this comment.
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.
Collaborator
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.