feat: add bucket finder
This commit is contained in:
parent
4b42f4c12a
commit
32be1eaa95
6 changed files with 126 additions and 1 deletions
30
lib_vector_search/include/bucket_finder.h
Normal file
30
lib_vector_search/include/bucket_finder.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include "finder.h"
|
||||
#include "word_list.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
class Bucket {
|
||||
private:
|
||||
std::map<const char, WordRefList> groups_;
|
||||
|
||||
public:
|
||||
Bucket() = default;
|
||||
|
||||
void insert(const WordList &word_list, size_t first_index, size_t last_index);
|
||||
|
||||
std::forward_list<const std::string *>
|
||||
find_prefix(std::string_view search_term) const;
|
||||
};
|
||||
|
||||
class BucketFinder : public Finder {
|
||||
private:
|
||||
std::vector<Bucket> buckets_;
|
||||
|
||||
public:
|
||||
BucketFinder(const WordList &word_list);
|
||||
|
||||
std::forward_list<const std::string *>
|
||||
find_prefix(std::string_view search_term) const override;
|
||||
};
|
|
@ -22,6 +22,7 @@ public:
|
|||
|
||||
class WordRefList : public std::vector<const std::string *> {
|
||||
public:
|
||||
WordRefList() = default;
|
||||
WordRefList(const WordList &source);
|
||||
|
||||
static void find_prefix_in_range(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue