Code Monkey home page Code Monkey logo

crunch-rs's People

Contributors

chevyray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crunch-rs's Issues

Removing Clone requirement

Would it be possible to somehow remove the T: Clone restriction for items? I would think that this should improve performance (especially if the T has some complex data), and possibly streamline the code itself?

It might be possible to do with if the PackedItem<T> would hold references to T, using Packer for lifetime. Another option (but i'm not certain it will work), is for fn pack() to take the ownership of the self.items_to_pack (replacing it with an empty vec), but that seem to conflict with fn pack_into_po2() which can call pack() multiple times. Lastly, perhaps the packed structure could just store a vector of usize, referencing the indexes of self.items_to_pack.

One thing to note - I believe it would be possible to optimize this only if all public API would become consuming, e.g. pack(self, ...) instead of pack(&mut self, ...) (and same for pack_into_po2)

Generalize to arbitrary shapes

Stuff you probably already know

Algorithms that pack arbitrary shapes are useful for a variety of applications. For example, a manufacturer can pack parts to be cut from a sheet of material so as to minimize the amount of material wasted. In the most general setting the problem has no known solution. Particular cases, like the one this crate solves, can be shown to be NP-complete. But as with many NP-complete problems, there are approximating algorithms that do pretty well in practice.

Arbitrary shapes

It would be nice to have a crate that can pack arbitrary shapes. Such a crate, if it were generic, would have many potential uses.

impl Debug for more types

Most types benefit from a Debug implementation, and it looks like only Rect supports it in this crate right now.

Specifically, the lack of the Debug trait for PackedItem means that you can't .unwrap() or .expect() the result of Packer::pack.

I think you should be able to add #[derive(Debug)] to all of {Item, PackedItem, PackedItems, Packer, and Rotation}. It looks like maybe you were avoiding it on the generic types but the derive macro should handle the generic type correctly for this crate's purposes.

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.