implement 'exists' function on bro-tree as well, and benchmark it compared to string-set

This commit is contained in:
2024-09-09 15:57:58 +01:00
parent fc0fd6923b
commit b7a365c6b8
7 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
structure BuildExistsStringSet =
struct
fun helpExists (pos, trie, acc) =
if pos = Vector.length WordsList.words then
acc
else
let
val word = Vector.sub (WordsList.words, pos)
val newAcc = StringSet.exists (word, trie)
val acc = newAcc orelse acc
in
helpExists (pos + 1, trie, acc)
end
fun exists trie = helpExists (0, trie, true)
fun main () =
let
val endTrie =
Vector.foldl StringSet.insert StringSet.empty WordsList.words
val startTime = Time.now ()
val wordsExist = exists endTrie
val finishTime = Time.now ()
val searchDuration = Time.- (finishTime, startTime)
val searchDuration = Time.toString searchDuration ^ "\n"
in
print searchDuration
end
end
val _ = BuildExistsStringSet.main ()