faster new contains search

added a wordlist to the trie, containing an array of all the words
This commit is contained in:
neon443 committed 2026-03-15 01:28:02 +00:00
1 parent 9dac5f6939
commit 9e2bb928ee
2 files changed
+13 -14

No files matched your search

+5 -2
View File
@@ -17,9 +17,12 @@ class TrieNode: Codable {
class Trie: ObservableObject {
var root: TrieNode = TrieNode()
var dict: [String:Emoji] = [:]
var wordlist: [String] = []
func insert(word: String) {
let word = word.lowercased()
wordlist.append(word)
var currentNode = root
let indices = word.indices
let last = indices.last
@@ -38,7 +41,7 @@ class Trie: ObservableObject {
}
}
func search(for query: String) -> Bool {
func search(exactly query: String) -> Bool {
var currentNode = root
for char in query.lowercased() {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.