Giter VIP home page Giter VIP logo

Comments (2)

coriolinus avatar coriolinus commented on May 26, 2024

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 Nth, 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.

pickfire avatar pickfire commented on May 26, 2024

Oh, I forgot about bigint.

from counter-rs.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.