I love performance

This commit is contained in:
Noa Aarts 2025-12-10 23:50:08 +01:00
parent 9367dc0caf
commit 338888133c
Signed by: noa
GPG key ID: 1850932741EFF672
2 changed files with 8 additions and 9 deletions

View file

@ -34,7 +34,9 @@ impl Adjacencies {
pub fn reset(&mut self) { pub fn reset(&mut self) {
self.amap.iter_mut().for_each(|bitvec| { self.amap.iter_mut().for_each(|bitvec| {
if bitvec.any() {
bitvec.clear(); bitvec.clear();
}
}) })
} }
@ -45,7 +47,7 @@ impl Adjacencies {
}) })
} }
fn intersect(&self, other: &Adjacencies) -> Adjacencies { pub fn intersect(&self, other: &Adjacencies) -> Adjacencies {
Adjacencies { Adjacencies {
amap: self amap: self
.amap .amap
@ -154,10 +156,6 @@ impl Seating {
} }
} }
fn make_clone(&self) -> Self {
self.clone()
}
fn empty_table_coords(&self) -> Vec<(usize, Side)> { fn empty_table_coords(&self) -> Vec<(usize, Side)> {
self.people_top self.people_top
.iter() .iter()

View file

@ -7,16 +7,17 @@ use std::{
use shuffles::*; use shuffles::*;
fn main() { fn main() {
for size in 0..17 { for size in 0..18 {
let table = Seating::make_seating(size); let table = Seating::make_seating(size);
println!("We have a table\n{table}"); println!("We have a table\n{table}");
let mut corot = table.calc_alternatives(size); let mut corot = table.calc_alternatives(size);
println!("searching size {size}"); println!("searching size {size}");
let mut total = 0;
loop { loop {
match Pin::new(&mut corot).resume(()) { match Pin::new(&mut corot).resume(()) {
CoroutineState::Yielded(val) => println!("found setting\n{val}"), CoroutineState::Yielded(_val) => total += 1,
CoroutineState::Complete(total_checked) => { CoroutineState::Complete(total_checked) => {
println!("checked {total_checked} in total"); println!("checked {total_checked} in total to find {total} valid alternatives");
break; break;
} }
} }