Words order in Dictionary is now stable

main
Inga 🏳‍🌈 3 years ago
parent 02eb57cd8d
commit 33914eaba3
  1. 2
      src/anagram_analyzer.rs
  2. 2
      src/dictionary_builder.rs
  3. 5
      src/vector_alphabet.rs

@ -53,7 +53,7 @@ pub fn analyze_anagrams(anagram_vector: Vec<usize>, dictionary: &Dictionary, per
process_anagram_chunk(&chunk, phrase_length, hashes_to_find, &mut result);
}
//println!("{} {}", anagram_logger::get_anagram_vector_view(&anagram_vector, dictionary), total);
//println!("{} {}", crate::solution::get_anagram_vector_view(&anagram_vector, dictionary), total);
result
}

@ -75,7 +75,7 @@ impl Dictionary {
}
let mut words_by_vectors: Vec<_> = words_by_vectors.into_values().collect();
words_by_vectors.sort_by_key(|(vector, _)| vector.norm);
words_by_vectors.sort_by_cached_key(|(vector, _)| (vector.norm, vector.get_key()));
words_by_vectors.reverse();
let mut vectors = vec![];

@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fmt;
use packed_simd;
#[derive(Debug)]
@ -36,6 +37,10 @@ impl Vector {
return None;
}
}
pub fn get_key(&self) -> String {
format!("{:?}", self.simd_vector)
}
}
pub struct Alphabet {

Loading…
Cancel
Save