handle duplicates in insertion into trie properly (return same trie if it already has a FOUND/FOUND_WITH_CHILDREN node awith that key, or change tag of node from CHILDREN to FOUND_WITH_CHILDREN to mark it as inserted

This commit is contained in:
2024-09-08 04:41:14 +01:00
parent 88c48b0592
commit 36c9b45c1a
3 changed files with 41 additions and 15 deletions

Binary file not shown.

View File

@@ -136,6 +136,17 @@ struct
print "StringSet.remove: passed remove5\n"
end
fun insert1 () =
let
val trie = StringSet.empty
val _ = assertFalse (StringSet.exists ("abc", trie), "abc does not exist before it is added to trie")
val trie = StringSet.insert ("abc", trie)
val _ = assertTrue (StringSet.exists ("abc", trie), "abc exists after being addedd to trie")
in
print "StringSet.insert: passed add1\n"
end
fun run () =
let
val _ = testExists ()
@@ -146,6 +157,8 @@ struct
val _ = remove3 ()
val _ = remove4 ()
val _ = remove5 ()
val _ = insert1 ()
in
()
end