Add 'string-tries-sml/' from commit 'd056e08ce768e014ab409c7f63e8fd0adfc1dff2'
git-subtree-dir: string-tries-sml git-subtree-mainline:dba78da7ecgit-subtree-split:d056e08ce7
This commit is contained in:
34
string-tries-sml/bench/build-exists-string-set.sml
Normal file
34
string-tries-sml/bench/build-exists-string-set.sml
Normal file
@@ -0,0 +1,34 @@
|
||||
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.toMilliseconds searchDuration
|
||||
val searchDuration = LargeInt.toString searchDuration ^ "\n"
|
||||
in
|
||||
print searchDuration
|
||||
end
|
||||
end
|
||||
|
||||
val _ = BuildExistsStringSet.main ()
|
||||
Reference in New Issue
Block a user