Comments (2)
most_common
already returns all elements sorted by frequency. If you want to truncate the list to size N
, you can do most_common().truncate(N)
. If you just want the N
th, you can do most_common()[N]
. If there's a problem with this implementation, it's that it returns too many elements, not too few.
WRT Clone
vs Copy
: when N: Copy
, then the use of Clone
isn't any more expensive than just copying the numbers; it compiles down to the same copy. The reason we bound N: Clone
instead of Copy
is that there are users of this library who need to count large sets, and use a bigint type for N
. Bigints are often Clone
but not Copy
. This is a zero-cost abstraction: a user using the default usize
, or any other Copy
type , doesn't pay extra for it, but users who need more expansive types can have them.
from counter-rs.
Oh, I forgot about bigint.
from counter-rs.
Related Issues (14)
- Use defaultmap crate HOT 3
- Add/Sub clone self unnecessarily HOT 7
- impl<T> FromIterator<(T, usize)> for Counter<T>? HOT 2
- Counter doesn't derive Debug HOT 1
- Make Counter generic over the count type? HOT 5
- Add into_hashmap function
- is_subset / is_superset methods? HOT 8
- Suggestion: add 'multiset' and 'bag' tags to repository, README and Cargo.toml
- Suggestion: make Counter generic over the hashing algorithm HOT 2
- min count + into HOT 2
- Refactoring & Optional data concurrency HOT 4
- Is the `zero` instance member still required?
- `impl PartialOrd` via `is_{sub,super}set` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from counter-rs.