diff options
Diffstat (limited to 'Homework/cs3460/typeahead/WordTree.hpp')
| -rw-r--r-- | Homework/cs3460/typeahead/WordTree.hpp | 34 |
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 |
