You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to get the key with the maximum and minimum number of duplicates. To do that with the current API, I have to convert it to a vec and use max_by. It would be great if HashBag had this functionality build in.
The text was updated successfully, but these errors were encountered:
Sorry, I wrote that example on my phone. The correct example would be this:
bag
.set_iter().fold((usize::MAX, usize::MIN), |(min, max),(_, val)| (std::cmp::min(min, val), std::cmp::max(max, val)))
That said, my point was that you don't need to copy everything into a Vec if you only want the min and/or max. If the above example is along the lines of what you are looking for, consider opening a PR.
I would like to get the key with the maximum and minimum number of duplicates. To do that with the current API, I have to convert it to a vec and use
max_by
. It would be great ifHashBag
had this functionality build in.The text was updated successfully, but these errors were encountered: