This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
VectorSearch/lib_vector_search/include/tree_finder.h

36 lines
698 B
C++

#pragma once
#include "finder.h"
#include "word_list.h"
#include <unordered_map>
class SearchTreeNode {
private:
WordRefList words_;
std::unordered_map<char, SearchTreeNode *> children_;
public:
~SearchTreeNode();
void insert(std::string_view partial_word, const std::string *original_word);
const SearchTreeNode *find(std::string_view search_term) const;
WordRefList words() const;
};
class SearchTree : public SearchTreeNode {
public:
SearchTree(const WordList &word_list);
};
class TreeFinder : public Finder {
private:
SearchTree search_tree_;
public:
TreeFinder(const WordList &word_list);
WordRefList find_prefix(std::string_view search_term) const override;
};