Crates.io | pack_it_up |
lib.rs | pack_it_up |
version | 1.0.0 |
source | src |
created_at | 2023-01-07 14:07:16.125929 |
updated_at | 2023-03-07 15:25:28.083552 |
description | pack_it_up is a simple Rust library that implements various bin packing algorithms |
homepage | |
repository | https://github.com/stevenliebregt/pack_it_up |
max_upload_size | |
id | 753041 |
size | 11,449 |
pack_it_up is a simple Rust library that implements various bin packing algorithms
use pack_it_up::offline::first_fit_decreasing::first_fit_decreasing;
struct MyItem {
some_content: i32,
size: usize,
}
impl Pack for MyItem {
fn size(&self) -> usize {
self.size
}
}
fn main() {
let my_items = vec![
MyItem { some_content: 1, size: 1, },
MyItem { some_content: 2, size: 2, },
MyItem { some_content: 3, size: 19, },
MyItem { some_content: 4, size: 17, },
MyItem { some_content: 5, size: 1, },
];
let mut bins = first_fit_decreasing(20, my_items);
}
The above will result in 2 full bins, one with sizes 19 and 1, and the other with sizes 17, 2 and 1.