Attempt to reduce additional manual comparison upon resume
Dependencies
- [2]
AOO3FCSGCargo clippy, tweaks, etc - [3]
QEKHTVB7Get most things semi-working except the final sort - [4]
LLFG625IShould be all the database functions I need - [5]
CYDK6S5LFix bugs - [*]
5Y7ZXB53Start picker UI - [*]
HMOBTVJ4Initialize crate and add expected dependencies - [*]
YCWYAX6KFunctions for scraping names integrated enough to test (they don't work yet) - [*]
RNW6D777Minor tidy
Change contents
- edit in src/pick.rs at line 1
use crate::depth_check::depths; - edit in src/pick.rs at line 56
let pdb = db.clone(); - edit in src/pick.rs at line 58
// If this task fails the worst that will happen is I compare more// names than I otherwise would. .let check =tokio::spawn(async move {let prefs =pdb.list_preferences().await.unwrap_or_else(|_| Vec::new());tokio::task::spawn_blocking(move || {depths(prefs.into_iter().map(|(better, worse)| {(better as usize, worse as usize)}))}).await.unwrap_or_else(|_| Vec::new())}); - replacement in src/pick.rs at line 73
for name in db.list_names().await.ok().into_iter().flat_map(Vec::into_iter){match ntx.send(name).await {Ok(_) => (),Err(_) => break,let names = db.list_names().await;let depth_list = check.await.unwrap_or_else(|_| Vec::new());for name in names.ok().into_iter().flat_map(Vec::into_iter) {if depth_list.get(name.1 as usize).cloned().unwrap_or(0)< count.into(){match ntx.send(name).await {Ok(_) => (),Err(_) => break,} - replacement in src/pick.rs at line 116
let pivot: *mut IDedName =unsafe { i.offset(j.offset_from(i) / 2) };let pivot: *mut IDedName = unsafe { i.offset(j.offset_from(i) / 2) }; - edit in src/main.rs at line 3[9.33][10.210]
mod depth_check; - file addition: depth_check.rs[8.15]
pub fn depths<I: IntoIterator<Item = (usize, usize)>>(preferences: I,) -> Vec<usize> {let mut workspace = Vec::new();let mut result = Vec::new();for (better, worse) in preferences {while workspace.len() <= worse {workspace.push(Vec::new());result.push(0);}workspace[worse].push(better);}let mut stack: Vec<(usize, Option<usize>)> =(0..workspace.len()).rev().map(|x| (x, None)).collect();while let Some((i, r)) = stack.pop() {let d = std::mem::take(&mut workspace[i]);if !d.is_empty() {stack.push((i, r));for j in d {stack.push((j, Some(i)));}} else if let Some(s) = r {result[s] = result[s].max(result[i] + 1);}}result}