1
0
Fork 0

Merging upstream version 26.2.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 22:00:08 +01:00
parent a5399bd16b
commit 4d0635d636
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
85 changed files with 57142 additions and 52288 deletions

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use rustc_hash::FxHashMap as HashMap;
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct TrieNode {
is_word: bool,
children: HashMap<char, TrieNode>,
@ -35,21 +35,12 @@ impl TrieNode {
}
}
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Trie {
pub root: TrieNode,
}
impl Trie {
pub fn new() -> Self {
Trie {
root: TrieNode {
is_word: false,
children: HashMap::new(),
},
}
}
pub fn add<'a, I>(&mut self, keys: I)
where
I: Iterator<Item = &'a String>,
@ -59,7 +50,7 @@ impl Trie {
for c in key.chars() {
current = current.children.entry(c).or_insert(TrieNode {
is_word: false,
children: HashMap::new(),
children: HashMap::default(),
});
}
current.is_word = true;