summaryrefslogtreecommitdiff
path: root/Homework/cs3460/typeahead/WordTree.hpp
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-07-02 11:55:17 -0700
commit6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch)
treeed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs3460/typeahead/WordTree.hpp
downloadmisc-undergrad-main.tar.gz
misc-undergrad-main.zip
Diffstat (limited to 'Homework/cs3460/typeahead/WordTree.hpp')
-rw-r--r--Homework/cs3460/typeahead/WordTree.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Homework/cs3460/typeahead/WordTree.hpp b/Homework/cs3460/typeahead/WordTree.hpp
new file mode 100644
index 0000000..0ef8ce0
--- /dev/null
+++ b/Homework/cs3460/typeahead/WordTree.hpp
@@ -0,0 +1,34 @@
+#include <array>
+#include <cstring>
+#include <iostream>
+#include <memory>
+#include <queue>
+#include <stdexcept>
+#include <string>
+#include <vector>
+
+#ifndef WORDTREE_HPP
+ #define WORDTREE_HPP
+
+class WordTree
+{
+ struct TreeNode
+ {
+ bool m_endOfWord;
+ std::array<std::shared_ptr<TreeNode>, 26> m_children;
+
+ TreeNode();
+ };
+ std::shared_ptr<TreeNode> m_root;
+
+ public:
+ WordTree();
+ ~WordTree();
+
+ void add(const std::string& word);
+ bool find(const std::string& word);
+ std::vector<std::string> predict(std::string partial, std::uint8_t howMany);
+ std::size_t size();
+};
+
+#endif // WORDTREE_HPP \ No newline at end of file