From 226dee33ccddb5379469a683e9437573e90c12da Mon Sep 17 00:00:00 2001 From: Shautvast Date: Tue, 12 Nov 2024 12:33:21 +0100 Subject: [PATCH] comments --- solution2/src/algorithm.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solution2/src/algorithm.rs b/solution2/src/algorithm.rs index 036423a..50e5a3c 100644 --- a/solution2/src/algorithm.rs +++ b/solution2/src/algorithm.rs @@ -81,12 +81,14 @@ pub fn find_optimal_path( let mut current_path; while running && !paths_to_consider.is_empty() { - paths_to_consider.sort(); + // would have liked a list like datastructure that is guaranteed to be sorted + // BTreeSet would be nice, but equals/hash/cmp calls would be unneeded overhead + paths_to_consider.sort(); // but this is also overhead compared to BTreeSet current_path = paths_to_consider.last().unwrap().clone(); // assert = Some // evict paths that are of max len while current_path.length() >= t { - _ = paths_to_consider.pop(); + _ = paths_to_consider.pop(); // discards element that = current_path if current_path.value() > max.value() { max = current_path.clone(); // sorry }